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
| fun calculateDiscount(person: Person) : Int { | |
| //... | |
| } |
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
| class Person(private val name: String, | |
| val age: Int, | |
| val income: Int = 0) |
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
| sealed class TwoFactorResult { | |
| object Success : TwoFactorResult() | |
| data class RetryTwoFactorAuth(val token: String) : TwoFactorResult() | |
| data class Fail(val errorMessage: String) : TwoFactorResult() | |
| data class RetrySocial(val errorMessage: String) : TwoFactorResult() | |
| } |
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
| sealed class SignInResult { | |
| data class Success(val token: String) : SignInResult() | |
| data class TwoFactorAuth(val token: String) : SignInResult() | |
| data class Fail(val token: String) : SignInResult() | |
| data class RetrySocial(val errorMessage: String) : SignInResult() | |
| } |
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
| warmWool.forEach { | |
| val yarn = when (it) { | |
| is Wool.Merino -> knit() | |
| is Wool.Alpaca -> knit() | |
| } | |
| } |
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
| val warmWool = yarnStash.filterIsInstance<Wool>() |
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
| val yarnStash: Sequence<Yarn> = listOf( | |
| Yarn.Cotton(), | |
| Yarn.Wool(), | |
| Wool.Merino(), | |
| Wool.Alpaca(), | |
| Yarn.Silk() | |
| ).asSequence() |
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
| val yarn: Yarn = when(spool) { | |
| is Yarn.Cotton -> knit() | |
| is Yarn.Silk -> knit() | |
| is Wool.Merino -> knit() | |
| is Wool.Alpaca -> knit() | |
| } |