One line if statement not working

前端 未结 8 910
遥遥无期
遥遥无期 2021-01-29 18:59
<%if @item.rigged %>Yes<%else%>No<%end%>

I was thinking of something like this?

if @item.rigged ? \"Yes\" : \"No\" 
<         


        
8条回答
  •  再見小時候
    2021-01-29 19:35

    Both the shell and C one-line constructs work (ruby 1.9.3p429):

    # Shell format
    irb(main):022:0> true && "Yes" || "No"
    => "Yes"
    irb(main):023:0> false && "Yes" || "No"
    => "No"
    
    # C format
    irb(main):024:0> true ? "Yes" : "No"
    => "Yes"
    irb(main):025:0> false ? "Yes" : "No"
    => "No"
    

提交回复
热议问题