Changeset 1780
- Timestamp:
- 11/25/08 06:08:11 (22 months ago)
- Location:
- cobra/trunk
- Files:
-
- 3 modified
-
Developer/IntermediateReleaseNotes.text (modified) (1 diff)
-
Source/Cobra.Lang/Native.cs (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/Developer/IntermediateReleaseNotes.text
r1769 r1780 226 226 227 227 * Fixed: Cannot properly invoke delegates whose delegate types come from binary libraries. 228 229 * Fixed: Cannot use `for` expressions on non-generic enumerables. ticket:85 -
cobra/trunk/Source/Cobra.Lang/Native.cs
r1778 r1780 758 758 } 759 759 760 static public List<TOut> For<TIn, TOut>(IEnumerable list, ForGet<TIn, TOut> forGet) { 761 List<TOut> results = new List<TOut>(); 762 foreach (TIn item in list) 763 results.Add(forGet(item)); 764 return results; 765 } 766 767 static public List<TOut> For<TIn, TOut>(IEnumerable list, ForWhereGet<TIn, TOut> forWhereGet) { 768 List<TOut> results = new List<TOut>(); 769 foreach (TIn item in list) { 770 TOut value; 771 if (forWhereGet(item, out value)) 772 results.Add(value); 773 } 774 return results; 775 } 776 760 777 static private void ProcessGetSliceArgs(int count, ref int? start, ref int? stop, ref int? step) { 761 778 if (start==null) -
cobra/trunk/Tests/240-generics/100-use-generics-collections/610-for-expr-generic-list.cobra
r1264 r1780 47 47 words = for word in words where word <> 'asdf' # assign for expr back to source variable 48 48 assert words == ['aoeu'] 49 50 # okay sneak in a non-generic for expr 51 ie as System.Collections.IEnumerable = [1, 2, 3] 52 assert [2, 4, 6] == for i in ie get 2*(i to int) 53 assert [4, 6] == for i in ie where (i to int) > 1 get 2*(i to int)
