Better lambda expressions
Posted: Thu Feb 24, 2011 11:44 am
It might be just me, but I find Cobra's lambda's expression ugly.
Instead of
and if we want the type
Not sure about anonymous methods, but maybe
These are just suggestions. I like my lambda example (inspired/stolen from boo), but not necessarily the anonymous methods.
What are yours thoughts? Maybe we could have something similar to C#, with the => operator.
On a side note, what's the status of Linq in Cobra?
Instead of
t.sort(do(a as int, b as int)=a.compareTo(b))
t.sort( { a,b | a.compareTo(b) } )
and if we want the type
t.sort( { a as int,b as int | a.compareTo(b) } )
Not sure about anonymous methods, but maybe
.callArithmeticOp(3, 4, {a as int, b as int|
return a * b})
These are just suggestions. I like my lambda example (inspired/stolen from boo), but not necessarily the anonymous methods.
What are yours thoughts? Maybe we could have something similar to C#, with the => operator.
On a side note, what's the status of Linq in Cobra?