Im reading some code, and I encountered the following ternary expression. how would you translate the following ternary operator to regular if statements?
( (vowel) ? ((consonant) ? "ay" : "yay") : "")
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like this:
Note that I’m using
returnbecause ternary operator is an expression whileifis a statement in Java, thus it doesn’t have a value. You must wrap this in a method returningString.