1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/pp.rb (PP::PPMethods#pp_hash): sort if

all keys are strings, symbols or integers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-07-07 06:39:56 +00:00
parent 0afe6cb08f
commit 174b77b280
2 changed files with 13 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Sat Jul 7 15:36:50 2007 Tanaka Akira <akr@fsij.org>
* lib/pp.rb (PP::PPMethods#pp_hash): sort if
all keys are strings, symbols or integers.
Sat Jul 7 15:30:05 2007 Koichi Sasada <ko1@atdot.net>
* insnhelper.ci (vm_yield_setup_args), vm.c, insns.def:

View file

@ -247,7 +247,14 @@ class PP < PrettyPrint
def pp_hash(obj)
group(1, '{', '}') {
seplist(obj, nil, :each_pair) {|k, v|
keys = obj.keys
if keys.all? {|k| k.respond_to? :to_str } ||
keys.all? {|k| k.is_a? Symbol } ||
keys.all? {|k| k.is_a? Integer }
keys.sort!
end
seplist(keys, nil, :each) {|k|
v = obj[k]
group {
pp k
text '=>'