Created
April 28, 2018 18:33
-
-
Save alexd1971/b584b27382a7e77ed3e4ae40063668a8 to your computer and use it in GitHub Desktop.
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
class UserId { | |
String _id; | |
UserId(this._id); | |
@override | |
bool operator == (other) { | |
return _id == other._id; | |
} | |
int get hashCode => _id.hashCode; | |
} | |
void main() { | |
final map = new Map<UserId,int>(); | |
var a = new UserId('1'); | |
var b = new UserId('2'); | |
map[a] = 1; | |
map[b] = 2; | |
print(map[new UserId('1')]); | |
print(map[new UserId('2')]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment