From: Wayne Brissette Date: 2011-10-11T19:32:32+09:00 Subject: Re: why does `a + f b` not parse? --Apple-Mail=_E9C34CB3-0133-4209-8A67-0D1B591DF5A2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On Oct 11, 2011, at 2:54 AM, Martin DeMello wrote: > ruby-1.9.2-p0 > 2 + sqrt 5 > SyntaxError: (irb):25: syntax error, unexpected tINTEGER, expecting > keyword_do or '{' or '(' > from /home/martin/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in = `
' >=20 > I can't see why that doesn't parse properly. >=20 > martin >=20 You have two options. First, you can tell ruby what library it needs to = load (in this case the Math library), or you can include it. You also = have to surround your number in parentheses ().=20 This means your code would either look like this: ruby-1.9.2-p290 :004 > 2 + Math.sqrt(5) =3D> 4.23606797749979=20 OR=20 ruby-1.9.2-p290 :005 > include Math =3D> Object=20 ruby-1.9.2-p290 :006 > 2 + sqrt(5) =3D> 4.23606797749979=20 Ironically, as somebody new to Ruby, I was just reading about Libraries = and Modules so your question was a good review for me. ;) Wayne --Apple-Mail=_E9C34CB3-0133-4209-8A67-0D1B591DF5A2--