From: Terry Improv_coder Date: 2011-07-27T12:09:15+09:00 Subject: Re: How do I pass a variable to the Chroinc library function? Thanks, Eric nextdate = Chronic.parse("next #{inputday}") This worked. I am a newbie to Ruby, and I don't know all the variable syntax and relationships yet. I appreciate it. Terry taz-uker. Eric Christopherson wrote in post #1013197: > On Tue, Jul 26, 2011 at 5:53 PM, Terry Improv_coder > wrote: >> nextdate = Chronic.parse('next inputday') > This sends it the exact string 'next inputday', when what you want to > do is make a string from 'next ' + the contents of inputday. There are > several ways to do that: > > # String interpolation (requires double quotes) > nextdate = Chronic.parse("next #{inputday}") > > # String concatenation (single or double quotes) > nextdate = Chronic.parse('next ' + inputday) > nextdate = Chronic.parse("next " + inputday) > > etc. > >> >> I have tried every $, @ , @@ and single quotes and double quote >> combinations I can think of. > > It sounds like you need to review the differences between global ($), > instance (@), and class (@@) variables, on the one hand; and local > variables. inputday is a local variable, since it doesn't start with a > distinguishing symbol; $inputday, @inputday, and @@inputday would all > be different. -- Posted via http://www.ruby-forum.com/.