Get N elements from array and if array is smaller than N, fill remaining
elements by some value
I'm curious what would be a better way of doing this?
This code obvious doesn't work since take expects only one argument, but
this is how I wish it would work
%w(a b c).take(5, "x") # => ["a", "b", "c", "x", "x"]
No comments:
Post a Comment