Changeset 1264
- Timestamp:
- 02/07/08 13:16:52 (4 years ago)
- Location:
- cobra/trunk
- Files:
-
- 3 modified
-
Source/CobraLang.cs (modified) (2 diffs)
-
Source/Expr.cobra (modified) (1 diff)
-
Tests/240-generics/100-use-generics-collections/610-for-expr-generic-list.cobra (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/CobraLang.cs
r1229 r1264 603 603 public delegate bool ForWhereGet<TIn, TOut>(TIn inValue, out TOut outValue); 604 604 605 static public IList<TOut> For<TIn, TOut>(IList<TIn> list, ForGet<TIn, TOut> forGet) {605 static public List<TOut> For<TIn, TOut>(IList<TIn> list, ForGet<TIn, TOut> forGet) { 606 606 // TODO: if possible, it might be nice to get the generic type of the list coming in and then make a constructed type from it with TOut. 607 607 List<TOut> results = new List<TOut>(list.Count); … … 611 611 } 612 612 613 static public IList<TOut> For<TIn, TOut>(IList<TIn> list, ForWhereGet<TIn, TOut> forWhereGet) {614 IList<TOut> results = new List<TOut>();613 static public List<TOut> For<TIn, TOut>(IList<TIn> list, ForWhereGet<TIn, TOut> forWhereGet) { 614 List<TOut> results = new List<TOut>(); 615 615 foreach (TIn item in list) { 616 616 TOut value; -
cobra/trunk/Source/Expr.cobra
r1262 r1264 830 830 _whereExpr = TruthExpr(_whereExpr).bindAll to TruthExpr # CC: axe cast when have "as same" 831 831 _getExpr.bindImp 832 ilist = .compiler.libraryBox('System.Collections.Generic. IList<of>')832 ilist = .compiler.libraryBox('System.Collections.Generic.List<of>') 833 833 _type = ilist.constructedTypeFor([_getExpr.type to !]) 834 834 -
cobra/trunk/Tests/240-generics/100-use-generics-collections/610-for-expr-generic-list.cobra
r1244 r1264 42 42 43 43 # where with a non bool-typed expression 44 stuff = 'aoeu a oeu'44 stuff = 'aoeu asdf' 45 45 words = for rawWord in stuff.split where rawWord.trim.length get rawWord.trim 46 assert words == ['aoeu', 'aoeu'] 46 assert words == ['aoeu', 'asdf'] 47 words = for word in words where word <> 'asdf' # assign for expr back to source variable 48 assert words == ['aoeu']



