Editing
Comparison Operations
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Comparison Operations == Comparison operations are fundamental to programming as they allow us to compare values and determine their relationship with each other. In Elixir, comparison operations are used to evaluate expressions and conditionally execute code based on the comparison results. === Equality Operators === The equality operators in Elixir are used to compare two values for equality. ==== == Operator ==== The `==` operator is used to check if two values are equal. It returns `true` if the values are equal and `false` otherwise. ==== === Operator ==== The `===` operator is another equality operator in Elixir. It not only checks if the values are equal but also compares their data types. It returns `true` if both the values and their data types are equal, and `false` otherwise. === Comparison Operators === In addition to the equality operators, Elixir provides several comparison operators to compare values in order to determine their relationship. ==== > Operator ==== The `>` operator is used to check if the left operand is greater than the right operand. It returns `true` if the condition is satisfied and `false` otherwise. ==== < Operator ==== The `<` operator is used to check if the left operand is less than the right operand. It returns `true` if the condition is satisfied and `false` otherwise. ==== >= Operator ==== The `>=` operator is used to check if the left operand is greater than or equal to the right operand. It returns `true` if the condition is satisfied and `false` otherwise. ==== <= Operator ==== The `<=` operator is used to check if the left operand is less than or equal to the right operand. It returns `true` if the condition is satisfied and `false` otherwise. === Examples === Here are some examples that demonstrate the usage of comparison operations in Elixir: ```elixir a = 5 b = 10 IO.puts(a == b) # Outputs false IO.puts(a > b) # Outputs false IO.puts(a < b) # Outputs true IO.puts(a >= b) # Outputs false IO.puts(a <= b) # Outputs true ``` === See Also === *[[Data Types in Elixir]] *[[Conditional Statements in Elixir]] *[[Logical Operators in Elixir]] [[Category:Elixir Programming]] [[Category:Operators]]
Summary:
Please note that all contributions to Elixir Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Elixir Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information