← Back to team overview

ooc-dev team mailing list archive

Re: Array literals? Variable arguments?

 

Thanks a lot!
In example readUntilStringB: func (args: ...) what is the type of args?

Damian

On Fri, Oct 15, 2010 at 9:52 AM, Friedrich Weber <
fred.reichbier@xxxxxxxxxxxxxx> wrote:

> Hey Damian,
>
> Yes and Yes! Here's a snippet showing both methods:
> http://bpaste.net/show/10150/
>
> In case bpaste.net goes down:
>
>  import structs/ArrayList
>>
>> printArray: func (a: ArrayList<String>) {
>>    for(i in 0..a size) {
>>        "%d) %s" format(i, a[i] toCString()) println()
>>    }
>> }
>>
>> readUntilStringA: func (a: ArrayList<String>) {
>>    "A" println()
>>    printArray(a)
>> }
>>
>> readUntilStringB: func (args: ...) {
>>    "B" println()
>>    a := ArrayList<String> new()
>>    args each(|arg|
>>        if(T != String)
>>            Exception new("NNNNOOOOOO") throw()
>>        a add(arg as String)
>>    )
>>    printArray(a)
>> }
>>
>> main: func {
>>    readUntilStringA(["1", "2"] as ArrayList<String>)
>>    readUntilStringB("1", "2")
>> }
>>
>
>
> Cheers,
>
> Friedrich
>
> _______________________________________________
> Mailing list: https://launchpad.net/~ooc-dev
> Post to     : ooc-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ooc-dev
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References