Don’t even dare to mention now that Python is the only one that have the whitespace quirks…
#!/usr/bin/ruby
def a(x=4)
x+2
end
b = 1
puts a + b # => 7
puts a+b # => 7
puts a+ b # => 7
puts a +b # => 3 !!!
puts b + a # => 7
puts b+a # => 7
puts b+ a # => 7
puts b +a # => 7
For those skeptical souls who don’t have ruby installed:
http://tryruby.hobix.com/
I’m sticking with Python!!!
That’s pretty ugly, but I got a better one still.
>> a = 1
=> 1
>> def a() 2 end
=> nil
>> a
=> 1
>> a()
=> 2
>> b = a
=> 1
>> b
=> 1
>> b()
NoMethodError: undefined method `b’ for main:Object
from (irb):33
from :0
I can’t take ruby serious as a programming language. That stuff will lead to horrible maintenance problems.
Meh, I’m one of the (many) people who actually like Python’s whitespace enforcement.
And even though the page you posted was Guido’s April Fool’s joke, I wish he would enforce it.
While I’ve never used Ruby, those do look like some pretty messed up quirks.
– Ryan
While I know the intent is to point out the flawes in whitespace interpretation in ruby, do note the date of the Van Rossum article.
April 1st.
Guido was joking, but Ruby flaw is not an April Fool’s joke and affects all Ruby programmers, which is the point of this blog note.