[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: String#% and a Hash
From: Ryan Davis <ryand-ruby () zenspider ! com>
Date: 2007-12-31 8:10:34
Message-ID: 6405ABE2-FF79-47F6-B8BC-684EDC79D88E () zenspider ! com
[Download RAW message or body]
On Dec 30, 2007, at 23:34 , Daniel Brumbaugh Keeney wrote:
> Ruby1.9 doesn't seem to accept hashes in the String#% method anymore.
> I use this a lot in conjunction with gettext[1], and am basically
> wondering if this is a language change or a 1.9 bug. It doesn't appear
> to be documented in Ruby1.8 or Ruby1.9. Thanks.
Did it ever? I think you're referring to this, right?
> Also you can write as:
> _("%{filename} was not found") % {:filename => "foo.rb"}
> _("%{filename1} and %{filename2} is not same file") % {:filename1 =>
> "foo.rb",
> :filename2 =>
> "bar.rb"}
> _("%{filename} is %{filesize} byte") % {:filename => "foo.rb",
> :filesize => 100}
that looks like a gettext extension of String#%, not part of 1.8 core:
> >> s = '%{a}'; s.%("a" => 42)
> ArgumentError: malformed format string - %{
> from (irb):8:in `%'
> from (irb):8
I know it works this way in python, and it is actually pretty nice.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic