Conditional replacements in rhtml

I am working on the Agile programming tutorial and trying out some
ruby code. Can someone tell me why the following works:

Display Cart

Your cart currently holds <%= @items.size %> <%= @items.size == 1 ? "item" : "items" %>.

while this does not?

Display Cart

Your cart currently holds <%= @items.size %> <%= if @items.size == 1 then "item" else "items" %>.


*** e-mail is not a secure channel ***
mailto:byrnejb.@harte-lyne.ca
James B. Byrne Harte & Lyne Limited
vox: +1 905 561 1241 9 Brockley Drive
fax: +1 905 561 0757 Hamilton, Ontario
= hal Canada L8E 3C3

Hi James,

To do this with an if statement:

<%if @items.size == 1 -%>item<% else -%>items<% end -%>

I like this better myself.

<%= @items.size == 1 ? “item” : “items” %>

~ Ben

Ben R. wrote:

Hi James,

To do this with an if statement:

<%if @items.size == 1 -%>item<% else -%>items<% end -%>

I like this better myself.

<%= @items.size == 1 ? “item” : “items” %>

~ Ben

This is probably more railsy.

Your cart currently holds <%= pluralize(@items.size,"item") %>.

you forgot the end after else “items”