L
Lars Olsson
Hi,
Yesterday I introduced a bug in one of my scripts after accidentally
deleting av space. It took me quite I while to find where the bug was,
but I still can't understand *why* the missing space leads to a
different result. Anyone out there that can explain it to me?
lasso@lasso-laptop:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
lasso@lasso-laptop:~$ irb
irb(main):001:0> elems = ['foo', 'bar', 'baz']
=> ["foo", "bar", "baz"]
irb(main):002:0> puts elems.count -1
0
=> nil
irb(main):003:0> puts elems.count - 1
2
=> nil
How does the missing space between the minus sign and the number 1
change the expression?
Any answers appreciated
/lasso
Yesterday I introduced a bug in one of my scripts after accidentally
deleting av space. It took me quite I while to find where the bug was,
but I still can't understand *why* the missing space leads to a
different result. Anyone out there that can explain it to me?
lasso@lasso-laptop:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
lasso@lasso-laptop:~$ irb
irb(main):001:0> elems = ['foo', 'bar', 'baz']
=> ["foo", "bar", "baz"]
irb(main):002:0> puts elems.count -1
0
=> nil
irb(main):003:0> puts elems.count - 1
2
=> nil
How does the missing space between the minus sign and the number 1
change the expression?
Any answers appreciated
/lasso