Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7456

Re: question regarding syntax of #{rand()}

Newsgroups comp.lang.ruby
Date 2022-05-10 09:44 -0700
References <o8cl5h12k365eosq8aro47si1reckooud6@4ax.com> <210rii-cgn.ln1@tempo.martinkl.dialup.fu-berlin.de> <rtdo5hlbh8jm2aglnk630j5qm4kejdcnoo@4ax.com>
Message-ID <f825f49b-52c2-4d39-9d5e-e470d84bd018n@googlegroups.com> (permalink)
Subject Re: question regarding syntax of #{rand()}
From Sophia Ding <2027dings78@moundsviewschools.org>

Show all headers | View raw


On Sunday, April 17, 2022 at 10:58:58 AM UTC-5, Benjamin L. Russell wrote:
> On Sat, 16 Apr 2022 16:21:56 +0200, Martin Klaiber 
> <usenet.martinkl@gmx.de> wrote: 
> 
> >Here it works when using double-quotes instead of single: 
> > 
> >| puts "Did #{@damage} damage!" 
> > 
> >Proof: 
> > 
> >| martinkl@maurice:~/src/eigene/ruby$ ./guard_dog.rb 
> >| Did 0 damage! 
> >| martinkl@maurice:~/src/eigene/ruby$ ./guard_dog.rb 
> >| Did 6 damage! 
> >| martinkl@maurice:~/src/eigene/ruby$ ./guard_dog.rb 
> >| Did 2 damage! 
> >| martinkl@maurice:~/src/eigene/ruby$
> Ah, I see; according to p. 35 of the book, 
> 
> > Well, the #{} magic (called string interpolation if you 
> > want to be super fancy) is possible only with 
> > double-quoted strings; it can’t be done with 
> > single-quoted ones. 
> 
> Apparently, I had better either differentiate more closely between 
> single and double quotes when reading the book, or increase my intake 
> of ginkgo biloba (which I have been too stingy to take recently) to 
> increase my memory. 
> 
> Thank you for your response; issue resolved.
> -- 
> Benjamin L. Russell / DekuDekuplex at Yahoo dot com 
> http://dekudekuplex.wordpress.com/ 
> Computer Science Document Proofreader/Editor 
> "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^
IDK what who you are

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar


Thread

question regarding syntax of #{rand()} Benjamin L. Russell <DekuDekuplex@Yahoo.com> - 2022-04-16 21:16 +0900
  Re: question regarding syntax of #{rand()} Martin Klaiber <usenet.martinkl@gmx.de> - 2022-04-16 16:21 +0200
    Re: question regarding syntax of #{rand()} Benjamin L. Russell <DekuDekuplex@Yahoo.com> - 2022-04-18 00:58 +0900
      Re: question regarding syntax of #{rand()} Sophia Ding <2027dings78@moundsviewschools.org> - 2022-05-10 09:44 -0700

csiph-web