The add method can take any type of object you choose, and will extract a
string representation from that object if it exposes one:
myString.add(someObject);
myString.add(???more text???);
If it is a part of a string that you want to add the StringBuf object, you can use the addSub method.
This method works in exactly the same way as the String class ??™ s substr method:
myString.addSub(???Big long text string ???, startPos, endPos);
You can even add ASCII character codes that will then be converted to the character representations
before being appended to your StringBuf object. You do this using the addChar method:
myString.addChar(101); // adds the character `e` to the StringBuf object
Finally, you can extract the string back out of the StringBuf object using the toString method:
var str : String = myString.toString();
Summary
Wow, this was been quite a chapter and much was discussed. Throughout the chapter, you learned the
following skills and information:
The various types in the haXe language
Using untyped code in haXe
Using the Date object
Using Array s, List s, Hash ??™ s, and IntHash objects
Manipulating values with operators
Manipulating numerical values with the Math class
Manipulating strings with the String , StringTools , and StringBuf classes
The next chapter introduces functions, conditional statements, loops, and iterators.
Pages:
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176