Created
July 29, 2022 06:33
-
-
Save ifalok007/892dbae098b9c005666a9cdf9aa06557 to your computer and use it in GitHub Desktop.
medium scala notes
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
object IdFactory { | |
private var counter = 0 | |
def create(): Int = { | |
counter += 1 | |
counter | |
} | |
} | |
val newId: Int = IdFactory.create()// YOU ACCESS OBJECTS BY ITS NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment