Fun with Ruby
-
I'm debugging a ruby program, while learning the language at the same time. First impressions - :wtf: :omg: :doh: Here are a few WTFs * Whitespace alters behavior
a + b
addsa
tob
(variables)a +b
calls methoda
* Reserved words can be used as method names * Methods can be eclipsed by variables with the same namedef foo
puts "I am a method"
endfollowed by
foo=42
puts foowill output 42 * Methods return the value of the last statement by default I'm sure there are many more. You folks who have to deal with this every day have my deepest condolences.
-
I'm debugging a ruby program, while learning the language at the same time. First impressions - :wtf: :omg: :doh: Here are a few WTFs * Whitespace alters behavior
a + b
addsa
tob
(variables)a +b
calls methoda
* Reserved words can be used as method names * Methods can be eclipsed by variables with the same namedef foo
puts "I am a method"
endfollowed by
foo=42
puts foowill output 42 * Methods return the value of the last statement by default I'm sure there are many more. You folks who have to deal with this every day have my deepest condolences.
I remember back in the early 90s I was using a product called SuperBase, I debugged to a line of code and was getting a really weird error, there was nothing wrong with the code, it was really simple but it was throwing an error on that line. I tried everything I could think of and eventually deleted the line and retyped it. Never saw the error again. Really weird...
Never underestimate the power of human stupidity RAH
-
I'm debugging a ruby program, while learning the language at the same time. First impressions - :wtf: :omg: :doh: Here are a few WTFs * Whitespace alters behavior
a + b
addsa
tob
(variables)a +b
calls methoda
* Reserved words can be used as method names * Methods can be eclipsed by variables with the same namedef foo
puts "I am a method"
endfollowed by
foo=42
puts foowill output 42 * Methods return the value of the last statement by default I'm sure there are many more. You folks who have to deal with this every day have my deepest condolences.
-
Reading the title I thought: Oh no! Silvio(*) has joined CP, may be I should leave ... *For Italians it is easier to understand
-
I remember back in the early 90s I was using a product called SuperBase, I debugged to a line of code and was getting a really weird error, there was nothing wrong with the code, it was really simple but it was throwing an error on that line. I tried everything I could think of and eventually deleted the line and retyped it. Never saw the error again. Really weird...
Never underestimate the power of human stupidity RAH
-
Reading the title I thought: Oh no! Silvio(*) has joined CP, may be I should leave ... *For Italians it is easier to understand