Page 1 of 1

1st question: List comprehensions?

PostPosted: Thu Feb 07, 2008 8:01 pm
by neuruss
Hello Chuck,

I've been looking into the docs and I haven't found anything about list comprehensions or anything similar.
I just tried compiling a simple case and it didn't work.
Are they implemented or have you plans to do it?

By the way, congratulations for the first release!
neuruss

Re: 1st question: List comprehensions?

PostPosted: Thu Feb 07, 2008 8:38 pm
by Charles
Hi neuruss,

Thanks.

Yes, Cobra has them:

See here: http://cobra-language.com/docs/manual/expressions/for.html

(The manual needs a real sidebar with one-click access to the topics.)

Note that the ordering means that when Cobra does have IDE support, you will get "intellisense" on the expression you are making:
print for name in names get name._

There is a bug in the current release that you cannot assign the expression back to the same variable like so:
names = for name in names where name.trim.length

That is already fixed and there will a 0.7.x release by Monday morning.

-Chuck