Forums

1st question: List comprehensions?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

1st question: List comprehensions?

Postby neuruss » Thu Feb 07, 2008 8:01 pm

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
neuruss
 
Posts: 23

Re: 1st question: List comprehensions?

Postby Charles » Thu Feb 07, 2008 8:38 pm

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
Charles
 
Posts: 2510
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron