DEV Community 👩‍💻👨‍💻


Posted on

ternary operator

the suspicious one

<% @users.each do |a_user| %>
    <td><%= a_user.username %></td>
    <td><%= a_user.private ? "Yes" : "No" %></td>
Enter fullscreen mode Exit fullscreen mode

a_user.private == true ? "Yes" : "No"
also works, but since private is boolean already, and ternary is testing boolean, can just edit it out

meaning: if a_user's private key is assigned value true, prints out yes. if not, prints out no

Top comments (0)

Stop sifting through your feed.

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.