This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
val choir = Choir() | |
val singerMeghan = Singer("Meghan") | |
choir += singerMeghan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
data class Singer(val name: String) | |
fun main() { | |
val choir = Choir() | |
val singerMeghan = Singer("Meghan") | |
choir += singerMeghan | |
if(singerMeghan in choir){ | |
println("Meghan is a part of the choir!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
operator fun contains(s: Singer) : Boolean { | |
return singers.contains(s) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
data class Singer(val name: String) | |
fun main() { | |
val choir = Choir() | |
val singerMeghan = Singer("Meghan") | |
choir += singerMeghan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Choir { | |
private val singers = mutableListOf<Singer>() | |
operator fun plusAssign(singer: Singer) { | |
singers.add(singer) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
class Choir { | |
private val singers = mutableListOf<Singer>() | |
fun addSinger(singer: Singer) { | |
singers.add(singer) | |
} |
NewerOlder