Skip to content

Ruby Gem to flatten nested collections into one dimensional representations.

License

Notifications You must be signed in to change notification settings

austenmadden/raze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raze

Ruby Gem to flatten nested collections into one dimensional representations.

https://rubygems.org/gems/raze

##Examples

test = {test1: ['test_string', :test_symbol], test2: {test_hash: ['test_string']}}

Raze.flatten(test)
=> [:test1, "test_string", :test_symbol, :test2, :test_hash, "test_string"]

You might be wondering how the flatten method above differs from flatten methods in array or hash ruby core libraries. Unfortunately on their own the core methods won't flatten values/recurse through hashes.

irb(main):010:0> a = {test1: ['test_string', :test_symbol], test2: {test_hash: ['test_string']}}
=> {:test1=>["test_string", :test_symbol], :test2=>{:test_hash=>["test_string"]}}
irb(main):011:0> a.flatten(30)
=> [:test1, "test_string", :test_symbol, :test2, {:test_hash=>["test_string"]}]

About

Ruby Gem to flatten nested collections into one dimensional representations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages