[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [OT] Swiftly return multiple values
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 5 Jun 2014 08:58:28 +0200
On Thu, Jun 5, 2014 at 12:10 AM, Jay Carlson <nop@nop.com> wrote:
> In fake Lua syntax, the Ruby approach would look like:
>
> sortedStrings = stringArray:sorted() doing (a, b)
> return a:uppercaseString() < b:uppercaseString()
> end
Boo (the second-greatest programming language from Brazil) does it like this:
result = [1, 2, 3].Find() do (item as int):
return item > 1
The rule is that if the last argument of a function is a function,
then it can be defined afterwards with a do-block.
(Boo looks like Python, but underneath it's a statically-typed
language with local type inference, which is a popular choice these
days)