|
CIS 700 Software
Tutorials
|
Site /
GotchasProgram:x = 2 if x == 1 puts 'one' elseif x == 2 puts 'two' else puts 'many' end Prints out:
Explanation:The misspelled word This is where syntax coloring can be a big help. I found this error when I noticed that Program:1 def one 2 two 3 end 4 5 one 6 7 def two 8 puts "success!" 9 end 10 11 one Problem:Line 5 results in undefined local variable or method `two' for main:Object but there is no problem with lines 2 or 11. Explanation:At line 2, Ruby assumes there will be a method |