a guest Aug 24th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # To use this, simply require this file and it will become an extension of the base Array class. As such you can then do
- # [1,2,].custom_flatten as in Array.flatten instance method.
- class Array
- def custom_flatten(array=self)
- array.each_with_object() do |e, flattened|
- flattened.push *(e.is_a?(Array) ? custom_flatten(e) : e)
RAW Paste Data