Skip to content

Instantly share code, notes, and snippets.

View gideondk's full-sized avatar

Gideon de Kok gideondk

View GitHub Profile
@gideondk
gideondk / stringit.rb
Created October 29, 2012 19:57 — forked from srpouyet/stringit.rb
Functional programming babysteps :) Code reduction ;-)
# Functional programming babysteps :)
# This Proc returns a "stringified" version of the object you passed it.
# Example:
#
# h = Hash[1,2,3,4,5,[8,9,{:age => 90},[[[[60,{"a" => "gho"}]]],{[:what, 0] => [4.0 => 88.7]}]]]4.0 => 88.7]}]]]
# => {1=>2, 3=>4, 5=>[8, 9, {:age=>90}, [[[[60, {"a"=>"gho"}]]], {[:what, 0]=>[{4.0=>88.7}]}]]}
# stringit[h]
#=> {"1"=>"2", "3"=>"4", "5"=> ["8","9",{"age"=>"90"},[[[["60", {"a"=>"gho"}]]], {["what", "0"]=>[{"4.0"=>"88.7"}]}]]}
stringit = Proc.new do |v|