From: Shashank Date Date: 2003-05-31T11:54:40+09:00 Subject: IF statement in ruby 1.8.0 (2003-05-26) [i386-mswin32] Just when I thought that I had perfectly understood the IF statement in Ruby, I had this humbling revelation: (line numbers for reference only) #---------------------------------------------------------------- 01: set_trace_func proc{|event, file, line, objId, binding, klass| 02: p [file,line] if(event == 'line') } 03: 04: a = 0 #<---- Remove this 0 05: if 06: true 07: puts 'here' 08: 10 09: else 10: puts 'there' 11: 20 12: end 13: 14: p a 15: 16: set_trace_func(nil) #----------------------------------------------------------------- This produces: ["C:/atest/tst_set_trace.rb", 4] ["C:/atest/tst_set_trace.rb", 6] <<< This is ok... ["C:/atest/tst_set_trace.rb", 6] <<< But why this ? ["C:/atest/tst_set_trace.rb", 7] here ["C:/atest/tst_set_trace.rb", 8] ["C:/atest/tst_set_trace.rb", 14] 0 ["C:/atest/tst_set_trace.rb", 16] Notice the line 6 traced twice ?? And now remove the 0 (just the constant, not the 'a = ' ) on line 4 to get: ["C:/atest/tst_set_trace.rb", 4] ["C:/atest/tst_set_trace.rb", 6] ["C:/atest/tst_set_trace.rb", 7] here ["C:/atest/tst_set_trace.rb", 8] ["C:/atest/tst_set_trace.rb", 14] 10 ["C:/atest/tst_set_trace.rb", 16] which is what I expected in the first place. Me lost :-| TIA, --shanko