From: Dark Ambient Date: 2006-07-01T09:26:10+09:00 Subject: Re: Order of precedence wow, while I've been using irb for some things, I am now a true believer. I have been struggling to understand a calculation in some code . Checking the calc in my head. It made me forget an important Ruby and probably all programming languages rule. Here is the code: left = 22 write = left/10 # I'm was thinking should return 2.2, but no it returns just 2 (no modulus) left = left - write*10 # based on the wrong head calculation above it was not allowing me to # what this value truly is. Well, lesson learned. Stuart On 6/30/06, Austin Ziegler wrote: > On 6/30/06, Dark Ambient wrote: > > Just checking > > > > if I have > > > > a = a - b*c > > > > b*c gets calculated first then that result is subtracted from a ? > > In other words, parantheses, in Ruby, is not necessary to make that > > calculation ? > > It's best to check this sort of thing in irb. > > -austin > -- > Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ > * austin@halostatue.ca * http://www.halostatue.ca/feed/ > * austin@zieglers.ca > >