[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rails
Subject:    [Rails] format question
From:       jamie () dang ! com (Jamie Orchard-Hays)
Date:       2005-01-30 19:17:45
Message-ID: 9C77BA0E-72F3-11D9-B269-000A95D17A50 () dang ! com
[Download RAW message or body]

Thanks for that!

Jamie

On Jan 30, 2005, at 2:04 PM, Samuel Kvarnbrink wrote:

> You can also use String#% (i.e. the modulo operator), which gives the 
> same result:
>
> <%= "%.2f" % @item.distance %>
>
> Looks cleaner (imho) when there's only one value involved, but 
> multiple values have to be put in an array, which looks a bit messy. I 
> tend to use String#% when there's only one value involved and sprintf 
> for multiple values.
>
> //samuel
>
> 2005-01-30 kl. 01.02 skrev Jamie Orchard-Hays:
>
>> Thanks, that did it. Is this the preferred syntax?
>>
>> <%= sprintf("%.2f",@item.distance) %>
>>
>> Jamie
>>
>> On Jan 29, 2005, at 6:58 PM, Johan S?rensen wrote:
>>
>>> sprintf("%.2f", 0.123456)
>> _______________________________________________
>> Rails mailing list
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>>
>
> ________________________
> Samuel Kvarnbrink
>
> blog: http://samuelk.info
>
> mail: samuel@acc.umu.se
>       samuel.kvarnbrink@minervaskolan.se
>       samuel.kvarnbrink@humlab.umu.se
>
>
> "On two occasions I have been asked [by members of Parliament!],
> Pray, Mr. Babbage, if you put into the machine wrong figures,
> will the right answers come out?' I am not able rightly to
> apprehend the kind of confusion of ideas that could provoke such
> a question."
> -- Charles Babbage
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic