Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> why would you want to use lambdas if you have generator expressions?

Lambdas (blocks) in Ruby are used for way, way more than just building or manipulating lists. For example, there is no need for the "with" keyword in Ruby, because you can just use blocks for that. As another example, you can specify a block to the Hash constructor to specify code that runs when a key is accessed that is not present.

> Range class: [i for i in range(10)]

That is not a range class, that is an expression for constructing a contiguous list of numbers. The Range class in Ruby is an actual class that you can instantiate and call methods on.

  ("a".."z").cover?("c")    #=> true
  ("a".."z").cover?("5")    #=> false
> personally I don't think there is much of a difference between Python and Ruby. One is more mature the other is way hipper and it comes down personal taste which one you choose.

They have similar capabilities but make very different choices in a lot of ways.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: