Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INDENT_STRING = " "
- def ph hash, indent = 0
- result = "{\n"
- hash.sort_by{|e|e.inspect}.each do |key, value|
- result << INDENT_STRING * (indent+1)
- value = if Hash === value
- ph value, indent + 1
- else
- value.inspect
- end
- result << "#{key.inspect} => #{value}\n"
- end
- result << INDENT_STRING * indent << "}"
- if indent.zero?
- puts result
- else
- result
- end
- end
- hash = {:a,4,6,"0x5QB527C",:o=,{:c,:q,:+,{:/,:-,:|,:&},:t,:A},:b,{:e,:d},:y,:x}
- ph hash
- # >> {
- # >> 6 => "0x5QB527C"
- # >> :a => 4
- # >> :b => {
- # >> :e => :d
- # >> }
- # >> :o= => {
- # >> :+ => {
- # >> :/ => :-
- # >> :| => :&
- # >> }
- # >> :c => :q
- # >> :t => :A
- # >> }
- # >> :y => :x
- # >> }
Add Comment
Please, Sign In to add comment