Commit 9fe8653e authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge branch 'iij-pr-string-percent'

parents 427ea605 4380f861
class String
def %(args)
if args.is_a? Hash
sprintf(self, args)
else
sprintf(self, *args)
end
end
end
##
# Kernel#sprintf Kernel#format Test
#assert('Kernel.sprintf') do
#end
assert('String#%') do
assert_equal "one=1", "one=%d" % 1
assert_equal "1 one 1.0", "%d %s %3.1f" % [ 1, "one", 1.01 ]
assert_equal "123 < 456", "%{num} < %<str>s" % { num: 123, str: "456" }
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment