[Swift-user] Question about arrays of struct data

Lorenzo Pesce lpesce at uchicago.edu
Wed Mar 20 13:53:06 CDT 2013


thanks Mike,

The reason why I eventually decided that the standard approach was better is that it is a lot easier to make sense out of the structured files for readData then trying to hack together a large structure with a lot of files (hundreds or more).
In fact it is so much better that I regret not having done it before :-)


On Mar 20, 2013, at 1:32 PM, Michael Wilde wrote:

>> I changed my mind, readData works just fine ;-)
> 
> OK.
> 
> If the arrays are of modest size, you can make them constant array constructors and then set the structure with a foreach and assignment statements.
> 
> Swift doesnt have structure initialization constructors, but perhaps it should, eg ala Perl.
> 
> - Mike
> 
> 
> ----- Original Message -----
>> From: "Lorenzo Pesce" <lpesce at uchicago.edu>
>> Cc: "Swift User Discussion List" <swift-user at ci.uchicago.edu>
>> Sent: Wednesday, March 20, 2013 1:21:29 PM
>> Subject: Re: [Swift-user] Question about arrays of struct data
>> 
>> I changed my mind, readData works just fine ;-)
>> 
>> On Mar 20, 2013, at 1:12 PM, Lorenzo Pesce wrote:
>> 
>>> I need to create a struct that will become more complex with time,
>>> let's say this is what it looks like now:
>>> 
>>> type Sample{
>>>   string name;
>>>   string dir;
>>> }
>>> 
>>> Then I need an array of such structs
>>> 
>>> Sample [] mySamples;
>>> 
>>> However, I would like to create the struct on the fly into the
>>> swift script itself. For arrays I would typically do
>>> string FileID [] =
>>> ["C440.TCGA-BR-7196-10A-01D-2053-08.2","C440.TCGA-CG-4477-10A-01D-1158-08.5"];
>>> 
>>> How can I do that for a struct? (I don't want to use readData, but
>>> I can if there is no other choice)
>>> 
>>> Thanks,
>>> 
>>> Lorenzo
>>> 
>>> _______________________________________________
>>> Swift-user mailing list
>>> Swift-user at ci.uchicago.edu
>>> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user
>> 
>> _______________________________________________
>> Swift-user mailing list
>> Swift-user at ci.uchicago.edu
>> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user
>> 




More information about the Swift-user mailing list