Seth Vargo 12/29/2012

Ruby Local Method map Shortcut

Read Original

This technical article explains Ruby's `&:method` syntax for simplifying `map` operations, detailing its limitations such as inability to call local methods or pass arguments. It then demonstrates a proof-of-concept hack to extend the Array#map method to accept a receiver and arguments, enabling calls like `arr.map(self, &:local_method)`.

Ruby Local Method map Shortcut

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser