Ruby 1.9 has some cool new features. One of them is the ability to define default values for the arguments passed to code blocks, like in the following example:
pow = proc { |a, b = 2| a**b } pow.call 3, 3 # 27 pow.call 3 # 9
This is very useful, for instance, when we dynamically create new methods using metaprogramming and want some of the arguments for these methods to be optional.
class MyMath class < < self define_method



Recent Comments