Re: [Vala] A few questions



Hi,

2009/11/30 Hugo Florentino <latinmidget gmail com>:
Hello,

I have recently found Vala/Genie, and I think this is a very interesting
project. Although I have learned some Java and can more or less understand
Vala, I find Genie more attractive because the syntax is much simpler and
IMHO has some similarity with Delphi, which is what I have used for my few
little programs.

Anyway, I have some doubts I would like to clear (and please forgive any
possible stupidity, I am not an experienced programmer).

As the documentation on Genie is still incomplete, I tried to do something
like this (without success):

[indent=2]
const MAXVALUE: int = 50
init
 myarray : array of int = {1..MAXVALUE}

Isn't there a similar way to declare an array using only minimum and maximum
values?
No, arrays indices always start from 0, so you just pass the length, e.g.
myarray : array of int = new array of int [50]
(I hope you don't mean the array should contain elements from 1 to 50)


This way of using two values for declaring a range is also quite useful for
other things, like cases:

case a
 when 1..100
   print "first hundred"
 when 101..200
   print "second hundred"

But I couldn't find such a thing in the available documentation. If there is
a way, please provide an example, otherwise I would suggest to implement it.
No, there is no such thing.



Also, while looking for genie-related stuff, it seems you can use the
backslash to split lines (at least that's what I see in
valageniescanner.vala, starting from line 485), however I have tried using
it (with different indentations) without success. Could anyone post a
snippet of how to use it, for example to pass parameters to a function, each
in a separate line?
[indent=2]
init
  string.join (",",    \
               "item1", \
               "item2")

the backslash must be the last character on the line


One last thing: is there a shuffle method for collections? I haven't been
able to find it.
I don't think so


Regards, Hugo

PS I placed different doubts in the same message because I didn't see any
rule to post each question separatedly when subcribing to the list. Let me
know if it is your policy to separate threads by topic.
That's fine, it is however a good idea to put genie somewhere in the
subject if you're talking about genie ;-)

HTH,
Abderrahim



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]