Chromium Code Reviews| Index: frog/leg/lib/core.dart |
| =================================================================== |
| --- frog/leg/lib/core.dart (revision 2753) |
| +++ frog/leg/lib/core.dart (working copy) |
| @@ -242,12 +242,22 @@ |
| throw "Unimplemented user-defined length."; |
| } |
| +bool isInt(var v) { |
| + return JS(@"($0 | 0) === $1", v, v); |
|
ahe
2011/12/22 14:18:05
Why not:
JS(@"($0 | 0) === $0", v);
floitsch
2011/12/22 14:36:19
I asked him to do it this way. This way generating
ahe
2011/12/22 14:41:22
I'm not sure I understand. Are you saying that you
floitsch
2011/12/22 15:13:21
sorry for the confusion. I asked him to do b. I fi
|
| +} |
| + |
| class int {} |
| class double {} |
| class String {} |
| class bool {} |
| class Object {} |
| -class List<T> {} |
| +class List<T> { |
| + factory List(int n) { |
| + if (!isInt(n)) throw "Invalid argument"; |
| + if (n < 0) throw "Negative size"; |
| + return JS(@"new Array($0)", n); |
| + } |
| +} |
| class Expect { |
| static void equals(var expected, var actual) { |