Changeset 2335 for cobra/trunk/HowTo/282-PassReferencesToMethods.cobra
- Timestamp:
- 03/20/10 04:42:28 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/HowTo/282-PassReferencesToMethods.cobra
r2127 r2335 47 47 for cust in customers, print cust 48 48 49 # Yes, there will be lambdas in a future version so 50 # the comparison can be inlined in the sort() call. 49 # you can localize the comparison code with a closure 50 customers.sort(do(a as Customer, b as Customer)) 51 return a.name.toLower.compareTo(b.name.toLower) 52 53 # or a lambda expression 54 customers.sort(do(a as Customer, b as Customer)=a.name.toLower.compareTo(b.name.toLower)) 51 55 52 56 def orderByName(a as Customer, b as Customer) as int is shared



