The Whitespace Thing

6 08 2006

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

Actions

Information

5 responses

6 08 2006
André Roberge's avatar André Roberge

For those skeptical souls who don’t have ruby installed:
http://tryruby.hobix.com/

I’m sticking with Python!!!

6 08 2006
Florian's avatar Florian

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.

6 08 2006
Ryan Rousseau's avatar Ryan Rousseau

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

6 08 2006
Michael Watkins's avatar Michael Watkins

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.

6 08 2006
Michał Kwiatkowski's avatar mousebender

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.

Leave a comment




Design a site like this with WordPress.com
Get started