[Swift-user] tutorial/understanding issue 7
Daniel S. Katz
dsk at ci.uchicago.edu
Thu Oct 14 12:08:24 CDT 2010
Hi,
Continuing my journey through the Swift tutorial (http://www.ci.uchicago.edu/swift/guides/tutorial.php), though the previous 6 messages are waiting for approval, as I was not a member of the swift-users list when I sent them...
In section 3.5, why can't I do this:
type messagefile;
app (messagefile t) greeting (string s[]) {
echo s[0] s[1] s[2] stdout=@filename(t);
}
messagefile outfile <"q5out.txt">;
#string words[] = ["how","are","you"];
string words[];
words[0] = "how;
words[1] = "are";
words[2] = "you";
outfile = greeting(words);
is the issue that swift doesn't know how large to make words[]?
I also tried:
string words[3];
but this also didn't work.
Do strings need to be assigned when they are declared? Is this a general rule for Swift variables?
I guess part of the reason this is confusing me is I see the following in the Swift userguide, which seems to declare an array before assigning any of its elements.
file a[];
file b[];
foreach v,i in a {
b[i] = p(v);
}
a[0] = r();
a[1] = s();
Thanks,
Dan
--
Daniel S. Katz
University of Chicago
(773) 834-7186 (voice)
(773) 834-3700 (fax)
d.katz at ieee.org or dsk at ci.uchicago.edu
http://www.ci.uchicago.edu/~dsk/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20101014/0e51a3bb/attachment.html>
More information about the Swift-user
mailing list