Skip to content

Instantly share code, notes, and snippets.

@morganp
Forked from Whoops/flatten.rb
Created September 2, 2010 02:14
Show Gist options
  • Save morganp/561729 to your computer and use it in GitHub Desktop.
Save morganp/561729 to your computer and use it in GitHub Desktop.
require 'pp'
a=[1,[2,[3]],4,5,[6,7,[8,9]]]
pp a.inject([]){|b,x| if Array===x then x.each {|y| b << y } else b << x end;b;}
#ruby numeric.rb 10000000.12355
a,b=ARGV[0].split('.');p a.reverse.gsub(/(\d{3})(?=\d)/,'\1,').reverse + "." + b
#ruby resolve.rb "Enumerable::Enumerator"
puts ARGV[0].split('::').inject(Kernel){|obj,str|obj.const_get(str)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment