Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Concepts]: add ternary operator #388

Closed
wants to merge 1 commit into from

Conversation

meatball133
Copy link
Member

@glennj
Copy link
Contributor

glennj commented Apr 21, 2023

Does this need to be a separate concept, or can it be mentioned in a Conditionals concept?

@meatball133
Copy link
Member Author

I mean, it could be, I did this mostly to avoid the concept of the conditional for becoming too long and I don't know if the exercise suits using ternary.

I am also planning to add if as a suffix to the about.md on conditionals (will do that this weekend). But I mean if you feel like adding this won't make the concept of the conditional too large, I think we can perhaps merge them

@glennj
Copy link
Contributor

glennj commented Apr 21, 2023

IMO it only needs to be very short:

## Ternary Operator

Crystal implements the familiar ternary operator: `condition ? expression_if_true : expression_if_false`

```crystal
1 == 0 ? "equal" : "not equal"
# => "not equal"
```

@meatball133
Copy link
Member Author

Yeah, I think we can merge them.

I will have to look over it later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Concepts]: Add Ternary Operator
2 participants