Give length a new name : alias « Method « Ruby






Give length a new name


class Array
  alias :len :length
end

[1, 2, 3, 4].len                                    # => 4

 








Related examples in the same category

1.Alias a old method a new name, then change the implementation of old method
2.Create a Wrapper method to alias
3.Redefining Backquotes
4.Aliasing Methods