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
Advertisements

Actions

Information

5 responses

6 08 2006
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

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

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

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
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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: