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

> Blocks + Procs + Lambdas are all function-adjacent. Can't we just call them functions?

Well, Ruby has functions, they're just called Procs. Lambdas are a special, more strict breed of Procs, and blocks are just (pretty complex) syntax sugar for passing a Proc to a method. The main function-like concept is always a Proc.

> Out of bounds indexes on Arrays/Maps return nil.

Calling the #[] or #slice method on an Array with an out-of bound index returns nil, calling the #fetch method raises an IndexError or returns an arbitrary default value. You can use whichever suits the situation.



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

Search: