Prev | Current Page 157 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

split(???,???);
You can have as long a delimiter as you like, though the delimiters are discarded in the split.
Part I: The Core Language
68
Converting an Array Back to a String
Once you perform the necessary operations against the items in your array, you can convert it back into
a string using the Arrays join method. join takes as its parameter the delimiter you want to use to glue
the items together and then returns the newly joined string:
var strArray : Array < String > = [???item1???,???item2???,???item3???];
var wholeStr : String = strArray.join(???,???); // will return ???item1,item2,item3???
Here is an example of parsing a string of properties and their values into a Hash Table . Type the code
into a new file and save as StringParsing.hx :
class StringParsing
{
public static function main()
{
var configStr : String = ???item1=val1 & item2=val2???;
var keyStr : String;
var valStr : String;
var htProps : Hash < String > = new Hash();
var prevKeyLoc : Int = 0;
var curKeyLoc : Int = 0;
var curValLoc : Int = 0;
curKeyLoc = configStr.


Pages:
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169