"Doug Edmunds" <dae_alt3 / juno.com> wrote in message news:3ab6a098$1_1 / news.pacifier.com... > This code comes from the online code examples for > the Programming Ruby book > ... > > but these don't (similar to irb): > p (1..5).sum #generates an error > p (1..5).product #generates an error > p ('a'..'m').sum("Letters: ") #generates an error > > However, this 2 step process works for the range: > aa = (1..5).sum > bb = (1..5).product > cc = ('a'..'m').sum("Letters: ") > p aa > p bb > p cc > > What is different about how ranges and arrays process > this code, that p /array/ works but p /range/ doesn't? > I think it's difference in operator precedence. Try following code: p (2.4/0.2).to_i # -> 12.0 p ((2.4/0.2).to_i) #-> 11 > #thanks > > -- doug edmunds > 19 March 2001 > > Park HeeSob