a Python person's experience with Ruby

Steve Howell showell30 at yahoo.com
Sat Dec 8 18:59:12 EST 2007


--- Bruno Desthuilliers > 
> > Another aspect of Ruby is that the final
> expression
> > evaluated in a method actually gets returned as
> the
> > result of a method,
> 
> Unless there's an explict return before...
> 
> > which has further implications on
> > whether "close" is simply evaluated or called.
> 
> I'm sorry but I'm not sure I get the point here.

I'm just giving another example that the following
seemingly innocuous line of code has lots of side
effects in both languages, but the two languages
differ:

    transaction.finish # last line in method

1) Some one new to Python might be surprised that
finish never gets invoked.

2) Some new to Ruby might be surprised that the
command above might actually cause the enclosing
method to return a non-nil value.

For this code:

   return table.get_apples # last line of get_getter()

1) Some one new to Python might be surprised to see
this code when get_apples is not explicitly written in
MyTable.

2) Some one new to Ruby might be surprised that
get_getter()() does not work as expected. 


    


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs



More information about the Python-list mailing list