# See the License for the specific language governing permissions and
# limitations under the License.
+#alt1 import standard
+#alt1 import standard::ropes
+
# A procedural program (without explicit class).
-meth first_word(s: String): String
+fun first_word(s: String): String
do
- var result = new String
+ var result: Buffer = new FlatBuffer
+ #alt1 result = new RopeBuffer
var i = 0
- while i < s.length and s[i] != ' ' do
- result.add(s[i])
+ while i < s.length and s.chars[i] != ' ' do
+ result.add(s.chars[i])
i = i + 1
end
- return result
+ return result.to_s
end
print(first_word("Hello world!"))