Created
August 23, 2019 11:03
-
-
Save atilaneves/2d3db10f19fc96a5bb01e15ae891250d to your computer and use it in GitHub Desktop.
UFCS
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
import mod; | |
struct Public { | |
int oops() { | |
return 42; | |
} | |
} | |
struct Nope { | |
} | |
int oops(T)(T obj) { | |
return 33; | |
} | |
void main() { | |
auto pub = Public(); | |
auto nop = Nope(); | |
assert(pub.oops == 42); | |
assert(nop.oops == 33); | |
} |
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
struct Private { | |
private int oops() { | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment