Skip to content

Instantly share code, notes, and snippets.

@aruld

aruld/gist:8172945

Last active Jan 1, 2016
Embed
What would you like to do?
void main() {
value employees = {"neal", "s", "stu", "j", "rich", "bob"};
String result = ",".join(employees
.filter((String e) => e.longerThan(1))
.map((String s) => s.segment(0, 1).uppercased + s.spanFrom(1))
);
// using a for comprehension
String result = ", ".join {
for (i in employees)
if (i.longerThan(1))
i.segment(0, 1).uppercased + i.spanFrom(1)
};
}
@gavinking

This comment has been minimized.

Copy link

@gavinking gavinking commented Jan 21, 2015

Just stumbled upon this. A couple of suggestions:

  1. As of Ceylon 1.1, the explicit type annotations in the anonymous functions are no longer required.
  2. We usually write x.segment(0, 1) as x[0:1], and x.spanFrom(1) as x[1...].

HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.