From: "mame (Yusuke Endoh)" Date: 2012-03-27T23:44:46+09:00 Subject: [ruby-core:43740] [ruby-trunk - Feature #5558][Assigned] String#% strange arity errors Issue #5558 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) This behavior is certainly intended. See [ruby-core:5161]. There is another example that behavior changes whether it is debug mode or not: Thread#abort_on_exception. Thread.new { raise } sleep 1 The above will terminate normally without -d. But it will blow up with -d. So, we should know that -d affects the behavior, IMO. -- Yusuke Endoh ---------------------------------------- Feature #5558: String#% strange arity errors https://bugs.ruby-lang.org/issues/5558#change-25247 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: When the number of arguments do not match the number of % parameters, the String#% method has some odd behavior. When too many, it seems to work fine, ignoring the extra arguments. "%s" % [1,2] #=> "1" But if `$DEBUG = true`, "%s" % [1,2] #=> ArgumentError: too many arguments for format string That doesn't seem right. Is it an error or isn't it? For too few arguments it is always an error: "%s" % [] #=> ArgumentError: too few arguments Personally, I think it should use '' for missing arguments. That would make it more flexible in practice. I consider the first $DEBUG issue a bug, and the later a feature. But I'll just call it a feature altogether to make things easier. -- http://bugs.ruby-lang.org/