Project

General

Profile

Actions

Bug #3829

closed

[doc] String#% and a hash

Added by DanielBovensiepen (Daniel Bovensiepen) about 14 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-09-15 trunk 29250) [x86_64-darwin10.3.2]
Backport:
[ruby-core:32386]

Description

=begin
String#% can also be used together with a Hash. The documentation is missing this point. This patch is adding documentation to rb_str_format_m and rb_f_sprintf.
=end


Files

sprintf_hash.patch (1.86 KB) sprintf_hash.patch DanielBovensiepen (Daniel Bovensiepen), 09/15/2010 02:23 AM
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r29254.
Daniel, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions #2

Updated by nagachika (Tomoyuki Chikanaga) about 14 years ago

=begin
In r29254 documentation for snprintf actually uses String#%.

Index: sprintf.c

--- sprintf.c (revision 29261)
+++ sprintf.c (working copy)
@@ -427,7 +427,7 @@

  • Exapmles:
  • sprintf("%d : %f" % { :foo => 1, :bar => 2 })
  •  #=> 1 : 2.000000
    
    • sprintf("%{foo}f" % { :foo => 1 })
    • sprintf("%{foo}f", { :foo => 1 })
    •  # => "1f"
      
    */

=end

Actions #3

Updated by DanielBovensiepen (Daniel Bovensiepen) about 14 years ago

=begin
Tomoyuki Chikanaga is complelty right! Also the previously existing example had the same issue:

Index: sprintf.c

--- sprintf.c (revision 29266)
+++ sprintf.c (working copy)
@@ -425,9 +425,9 @@ get_hash(volatile VALUE *hash, int argc, const VAL

  • %s style uses format style, but %{name} style doesn't.
  • Exapmles:
    • sprintf("%d : %f" % { :foo => 1, :bar => 2 })
    • sprintf("%d : %f", { :foo => 1, :bar => 2 })
    •  #=> 1 : 2.000000
      
    • sprintf("%{foo}f" % { :foo => 1 })
    • sprintf("%{foo}f", { :foo => 1 })
    •  # => "1f"
      
    */
    =end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0