Hi,
I attended a recent Rails Edge conference and seem to recall a new
built-in
shortcut to the following, frequently used, code:
<%= foo.nil? ? ‘’ : foo %>
Does anyone know what that might be?
Thanks,
Mark
Hi,
I attended a recent Rails Edge conference and seem to recall a new
built-in
shortcut to the following, frequently used, code:
<%= foo.nil? ? ‘’ : foo %>
Does anyone know what that might be?
Thanks,
Mark
On Feb 8, 2007, at 9:20 AM, Mark Veerman wrote:
Mark
Well, it’s nothing new:
<%= “#{foo}” %>
Since nil.to_s is an empty string and string interpolation does a .to_s
<%= foo.to_s %>
also works.
-Rob
Hi –
On Thu, 8 Feb 2007, Rob B. wrote:
also works.
<%= %> does a to_s too, so:
<%= foo %>
should be OK.
David
–
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs