Jim Bartlett wrote:
> 
> I created the "Inject" module as shown in Programming Ruby, p102-103 and
> included it in the Range class. When I try to get the sum of a range (ie
> (1..4).sum), it just spits out 1..4 and then an error:
> 
> undefined method "sum" for nil (NameError)
> 
> It works fine for arrays when included in class Array. What have I missed?
> Thanks.

Let me take a wild guess: You're using puts or print to print the value
and write:
 puts (1..4).sum
or something similar? The puts assumes the parenthesis as its argument
list, and what is returned by puts (nil) is the object that gets the sum
message. Try extra parenthesis.
 puts ((1..4).sum)

-- 
(\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
 ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 5. year  )
( \__\_/__/ ) _)Industrial economics and technological management(
 \____/_\____/ (____engineering.discipline_=_Computer::Technology___)