nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Intro `Task` and use in for Android's `run_on_ui_thread`
[nit.git]
/
tests
/
example_procedural_string.nit
diff --git
a/tests/example_procedural_string.nit
b/tests/example_procedural_string.nit
index
126fb85
..
4fbd8a9
100644
(file)
--- a/
tests/example_procedural_string.nit
+++ b/
tests/example_procedural_string.nit
@@
-14,17
+14,21
@@
# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
+#alt1 import core
+#alt1 import core::text::ropes
+
# A procedural program (without explicit class).
# A procedural program (without explicit class).
-meth first_word(s: String): String
+fun first_word(s: String): String
do
do
- var result = new String
+ var result: Buffer = new FlatBuffer
+ #alt1 result = new RopeBuffer
var i = 0
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
i = i + 1
end
- return result
+ return result.to_s
end
print(first_word("Hello world!"))
end
print(first_word("Hello world!"))