Created
November 1, 2014 17:23
-
-
Save d6y/8e770f7545e15c9aea13 to your computer and use it in GitHub Desktop.
Enumerations & Method Overload
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
| scala> :paste | |
| // Entering paste mode (ctrl-D to finish) | |
| object Colours extends Enumeration { | |
| val Red, Amber, Green = Value | |
| } | |
| object WeekDays extends Enumeration { | |
| val Mon,Tue,Wed,Thu,Fri = Value | |
| } | |
| object Functions { | |
| def f(x: Colours.Value) = "That's a colour" | |
| def f(x: WeekDays.Value) = "That's a weekday" | |
| } | |
| // Exiting paste mode, now interpreting. | |
| <console>:19: error: double definition: | |
| def f(x: Colours.Value): String at line 18 and | |
| def f(x: WeekDays.Value): String at line 19 | |
| have same type after erasure: (x: Enumeration#Value)String | |
| def f(x: WeekDays.Value) = "That's a weekday" | |
| ^ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment