Programming in Kotlin: Fundamentals

Aug 9 2022 Kotlin 1.6, Android 12, IntelliJ IDEA CE 2022.1.3

Part 1: Use Data Types & Operations

6. Combine Logical Operators

Episode complete

Play next episode

About this episode
See versions
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 5. Challenge: Booleans Next episode: 7. Branch with If Expressions & Scopes

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Pro subscription. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

This video Combine Logical Operators was last updated on Aug 9 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In the previous set of episodes, you saw how you can work with Boolean values, and how you could use comparison operators such as less than, greater than, equal to and not equal to, to compare values to each other.

val passingGrade = 50
val studentGrade = 50
val chrisGrade = 49
val samGrade = 99
val studentPassed = studentGrade >= passingGrade
val chrisPassed = chrisGrade >= passingGrade
val samPassed = samGrade >= passingGrade
println(chrisPassed == false)
val catName = "Jaspurr"
// val catName = "Jaspurr"
// println(!catName)
// AND Operator
// &&
val bothPassed = chrisPassed && samPassed

Demo 2

The OR operator is two vertical lines, or pipes like this:

// OR Operator
// ||
val eitherPassed = chrisPassed || samPassed
val anyonePassed = chrisPassed || samPassed || studentPassed
val everyonePassed = chrisPassed && samPassed && studentPassed
val meritAwardGrade = 90
val samHasPerfectAttendance = true
val samIsMeritStudent = samHasPerfectAttendance && samGrade > meritAwardGrade