Created
April 24, 2022 14:35
-
-
Save kuceraf/83dde2c63dab9dcf3b46c054d6b91789 to your computer and use it in GitHub Desktop.
Kotlin Design Patterns Visitor domain model
This file contains 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
abstract class Expression | |
class DoubleExpression(private val value: Double) : Expression() | |
class AdditionExpression( | |
private val left: Expression, | |
private val right: Expression | |
) : Expression() | |
fun main() { | |
// 1+(2+3) | |
AdditionExpression( | |
left = DoubleExpression(1.0), | |
right = AdditionExpression( | |
left = DoubleExpression(2.0), | |
right = DoubleExpression(3.0) | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment