13 lines
564 B
Text
13 lines
564 B
Text
module Substrings {
|
|
void run(String[] args = []) {
|
|
String s = args.size > 0 ? args[0] : "hello";
|
|
@Inject Console console;
|
|
console.print(
|
|
$|Original : { s .quoted()=}
|
|
|Remove first: { s.substring(1) .quoted()=}
|
|
|Remove first: {(s.size < 1 ? "" : s[1..<s.size ]).quoted()=}
|
|
|Remove last : {(s.size < 1 ? "" : s[0..<s.size-1]).quoted()=}
|
|
|Remove both : {(s.size < 2 ? "" : s[1..<s.size-1]).quoted()=}
|
|
);
|
|
}
|
|
}
|