This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rspec" | |
def flatten(arr) | |
return [arr] unless arr.is_a? Array | |
arr.reduce([]) { |concat, item| concat + flatten(item) } | |
end | |
RSpec.describe "Flattening a nested array" do | |
it "is valid for simple array" do |
OlderNewer