|
|
|
|
|
by Toutouxc
1649 days ago
|
|
> 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. |
|