4 ms·
I'll give you Erlang, but the Ruby solution is cheating rather.
by oofoe 16y ago
I'll give you Erlang, but the Ruby solution is cheating rather.
- judofyr 16y agoHere's a better Ruby version: module Enumerable def custom_flatten inject([]) do |result, element| if element.respond_to?(:custom_flatten) result.concat(element.custom_flatten) else result.push(element) end end end end Works on all Enumerables (Array, Hash, Set, etc)
- woodall 16y agoHow is Ruby's method and different than Groovy or JavaScript? I think their all pretty neat. Goes to show that there is always more than one way to skin a list.
- mishmash 16y agoTrue. I guess built-in functions shouldn't count.