Closed youssef-el-atmani closed 2 weeks ago
Why do you feel conditional statement is not correct?
Thank you @CouchofTomato for give me a chance to clarify my opinion
Why do you feel conditional statement is not correct?
Because the right name for something that could evaluates to true
or false
is a logical statement
not a conditional statement
,
for example :
#the followings are logical statements
5 == 7 #=> evaluates to `false`
6 >= 10 #=> evaluates to `false`
"hi" != "hello" #=> evaluates to `true`
# I think the following is a conditional statement, which is composed of : `if ... end`
if logical_statement
#do something
else
# do that another thing
end
I think logical statement ? <execute if true> : <execute if false>
is as whole a conditional statement.
@CouchofTomato May I ask you about what do you think?
Apologies for the delay.
I don't disagree with you that it's a logical expression. However you'll often see it referred to as the condition in a lot of places because it decides the executed part of a conditional operator. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator etc etc
So in isolation it definitely is a logical expression, but as part of a conditional operator it is often referred to as the condition. That's why I'm not sure it's wrong to leave it as it is.
What are your thoughts?
Thanks a lot @CouchofTomato, I guess it should stay as it is, conditional statement ? <execute if true> : <execute if false>
There is a little change I recommend based on the resources you provided: MDN and Microsoft
,
MDN: condition ? exprIfTrue : exprIfFalse
Microsoft: condition ? consequent : alternative
So I recommend replacing conditional statement
by condition
, because I guess it fits better
And It is up to you to decide whether that change is worth it or not
Yeah I'm happy to accept that. Thanks for working through this with me and I'm glad we arrived at a satisfactory outcome.
Clarified ternary operator syntax by replacing "conditional" with "logical" for accuracy.
Because
To make the ruby ternary operator syntax more accurate
This PR
Issue
Closes #XXXXX
Additional Information
Pull Request Requirements
location of change: brief description of change
format, e.g.Intro to HTML and CSS lesson: Fix link text
Because
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section