Check out a free preview of the full Introduction to Elm, v2 course

The "Booleans" Lesson is part of the full, Introduction to Elm, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Richard introduces how booleans and boolean operations are done in Elm.

Preview
Close

Transcript from the "Booleans" Lesson

[00:00:00]
>> Richard Feldman: So Booleans, Elm has two Boolean values, which I think is the correct number, if you're gonna have Booleans. True and false, they are capitalized like they are in Python, there is a very good specific reason for why they are capitalized unlike in JavaScript. Where they're not capitalized.

[00:00:14]
We're gonna know why they're capitalized a little bit later, but for now, it's enough to know that they happen to be capitalized in Elm. There are a bunch of different Boolean comparisons you can do, so == is one, so x == y, that will return either True or False.

[00:00:28]
You can say not, which is just a plain function in Elm. So in JavaScript, that's the exclamation point operator, but in all these there's no special syntax to that. There's just a function called not which if you give it true it returns false and vice versa. There's a short hand for not equal to.

[00:00:43]
So it's a slash equals. This comes from the ML family of languages which is what Elm syntax is based on. So they don't use exclamation point equals to mean not equals, they use slash equals. The idea is it's supposed to kinda look like if you squint an equal or the slash through it for like the not equal's Mathematical symbol.

[00:00:59]
But it does the same thing. It just means not equals. There's also and and or, which look and work the same way that they do in JavaScript. Nothing really special there, just same kind of semantics that you would find in most programming languages.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now