Updated examples based on the latest changes in the book
This commit is contained in:
parent
24d983c6ec
commit
a45abd2896
|
@ -8,7 +8,7 @@ fun main() {
|
|||
val alien1 =
|
||||
MutableNameAlien("Reverse Giraffe")
|
||||
val alien2 =
|
||||
FixedNameAlien("Krombopolis Michael")
|
||||
FixedNameAlien("Krombopulos Michael")
|
||||
|
||||
alien1.name = "Parasite"
|
||||
// Can't do this:
|
||||
|
|
|
@ -10,10 +10,10 @@ fun main() {
|
|||
v2 eq "Ontology"
|
||||
|
||||
// 'neq' means "not equal"
|
||||
v2 neq "Epistimology"
|
||||
v2 neq "Epistemology"
|
||||
|
||||
// [Error] Epistimology != Ontology
|
||||
// v2 eq "Epistimology"
|
||||
// [Error] Epistemology != Ontology
|
||||
// v2 eq "Epistemology"
|
||||
}
|
||||
/* Output:
|
||||
11
|
||||
|
|
|
@ -4,7 +4,7 @@ fun isClosed(hour: Int) {
|
|||
val open = 9
|
||||
val closed = 20
|
||||
println("Operating hours: $open - $closed")
|
||||
val status = hour < open || hour > closed
|
||||
val status = hour < open || hour >= closed
|
||||
println("Closed: $status")
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ fun isOpen1(hour: Int) {
|
|||
val closed = 20
|
||||
println("Operating hours: $open - $closed")
|
||||
val status =
|
||||
if (hour >= open && hour <= closed) // [1]
|
||||
if (hour >= open && hour < closed) // [1]
|
||||
true
|
||||
else
|
||||
false
|
||||
|
|
|
@ -4,7 +4,7 @@ fun isOpen2(hour: Int) {
|
|||
val open = 9
|
||||
val closed = 20
|
||||
println("Operating hours: $open - $closed")
|
||||
val status = hour >= open && hour <= closed
|
||||
val status = hour >= open && hour < closed
|
||||
println("Open: $status")
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ fun main() {
|
|||
val hour = 6
|
||||
println("Current time: " + hour)
|
||||
|
||||
val isOpen = hour >= opens && hour <= closes
|
||||
val isOpen = hour >= opens && hour < closes
|
||||
println("Open: " + isOpen)
|
||||
println("Not open: " + !isOpen)
|
||||
|
||||
val isClosed = hour < opens || hour > closes
|
||||
val isClosed = hour < opens || hour >= closes
|
||||
println("Closed: " + isClosed)
|
||||
}
|
||||
/* Output:
|
||||
|
|
|
@ -11,7 +11,7 @@ fun main() {
|
|||
val closes = 20
|
||||
println("Operating hours: " +
|
||||
opens + " - " + closes)
|
||||
hour >= opens && hour <= closes
|
||||
hour >= opens && hour < closes
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ fun main() {
|
|||
"Miffy",
|
||||
"Miller",
|
||||
"1-234-567890",
|
||||
"1600 Amphitheatre Parkway")
|
||||
"1600 Amphitheater Parkway")
|
||||
val newContact = contact.copy(
|
||||
number = "098-765-4321",
|
||||
address = "Brandschenkestrasse 110")
|
||||
|
|
Loading…
Reference in New Issue