0

Edit

If anyone could enlighten me of what you call if statements like those would be great! Thanks!


Quick question about "short" if statements (not sure what you call them),

I have

<%= (LeadsUser.IsAdministrator || LeadsUser.IsEditor || LeadsUser.IsSubsidiarie) ? "Currently logged in as: " : "" %>

<%= LeadsUser.IsSubsidiarie ? "Lead admin" : "" %>

<%= LeadsUser.IsAdministrator ? "Lead editor" : "" %>

<%= LeadsUser.IsEditor ? "Lead user" : "" %>

I know this is against DRY. I'm wondering can I combine those? Because some users are in multiple groups. I'd want it to say "Currnetly logged in as: Lead admin, lead editor", so depending on if LeadsUser.IsSubsidiarie is true aswell as IsAdministrator write ", lead editor" instead of "Lead editor".

2
  • 2
    "short" if statements (not sure what you call them) --> conditional operator Commented Aug 2, 2013 at 13:34
  • @TimSchmelter oo thanks ;) seems like I was right on the spot! Commented Aug 2, 2013 at 14:07

1 Answer 1

2

Like most of the times when writing a question I figure it out myself.

I figured you could nest the if's like this:

<%= LeadsUser.IsSubsidiarie && LeadsUser.IsAdministrator ? "Lead admin, lead editor" : (!LeadsUser.IsSubsidiarie ? "Lead editor" : "") %>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.