Advertisement
soywiz

Dart generic test

Oct 10th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. class MyGenericClass<TKey, TValue> {
  2.   Map<TKey, TValue> map;
  3.   MyGenericClass() {
  4.     this.map = new Map<TKey, TValue>();
  5.   }
  6.  
  7.   myAdd(TKey key, TKey/*TValue*/ value) {
  8.     this.map[key] = value; // Warning. Great!
  9.     return this;
  10.   }
  11.  
  12.   myGet(TKey key) => this.map[key];
  13. }
  14.  
  15. main() {
  16.   var test = new MyGenericClass<int, int>();
  17.   test.myAdd(10, 20);
  18.   print('Result is not ${test.myGet(10) - 1}');
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement