On Jan 26, 2024, at 10:52 PM, Robert Viragh <rvir...@gmail.com> wrote:
> 
> As a user of Elixir, it seems to me that I can write ternary expressions in 
> Elixir by treating the if statement as an expression and it remains highly 
> readable.

You are so close to being correct here. You're not "treating" a statement as an 
expression. Elixir has no if statement. It only has an if expression. This is 
by design and is common among functional languages.

It just so happens that Elixir is the first language where you have encountered 
it. It's great to see you have a "lightbulb moment" when a new concept fits 
together in your mind. Google for terms such as "expression based language" for 
more details.

That being said, yes, this insight offers you a deeper way of looking at 
conditional logic in Elixir. However, a ternary operator is distinct, as José 
pointed out, because it is an operator.

-Greg Vaughn

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/D6FD6023-2EEC-41CB-86E3-3EB51744169D%40gmail.com.

Reply via email to