* lib/pp.rb (PP::PPMethods#pp_hash): sort condition changed:
all keys have a same class which is kind of Comparable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
079976cac2
commit
acbffce267
@ -1,3 +1,8 @@
|
|||||||
|
Sat Jul 7 21:59:29 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/pp.rb (PP::PPMethods#pp_hash): sort condition changed:
|
||||||
|
all keys have a same class which is kind of Comparable.
|
||||||
|
|
||||||
Sat Jul 7 17:12:37 2007 Koichi Sasada <ko1@atdot.net>
|
Sat Jul 7 17:12:37 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* compile.c: use rb_bug() instead of rb_compile_error().
|
* compile.c: use rb_bug() instead of rb_compile_error().
|
||||||
|
@ -248,11 +248,12 @@ class PP < PrettyPrint
|
|||||||
def pp_hash(obj)
|
def pp_hash(obj)
|
||||||
group(1, '{', '}') {
|
group(1, '{', '}') {
|
||||||
keys = obj.keys
|
keys = obj.keys
|
||||||
if keys.all? {|k| k.respond_to? :to_str } ||
|
if 0 < keys.length
|
||||||
keys.all? {|k| k.is_a? Symbol } ||
|
key_class = keys[0].class
|
||||||
keys.all? {|k| k.is_a? Integer }
|
if key_class < Comparable && keys.all? {|k| k.class == key_class }
|
||||||
keys.sort!
|
keys.sort!
|
||||||
end
|
end
|
||||||
|
end
|
||||||
seplist(keys, nil, :each) {|k|
|
seplist(keys, nil, :each) {|k|
|
||||||
v = obj[k]
|
v = obj[k]
|
||||||
group {
|
group {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user