We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a4c635 commit c733151Copy full SHA for c733151
archive/k/kotlin/RemoveAllWhitespace.kt
@@ -0,0 +1,22 @@
1
+import kotlin.system.exitProcess
2
+
3
+fun main(args: Array<String>) {
4
+ val phrase: String = errorChecking(args)
5
+ println(removeWhitespace(phrase))
6
+}
7
8
+fun usageError() {
9
+ println("Usage: please provide a string")
10
11
12
+fun errorChecking(args: Array<String>): String {
13
+ if (args.size == 0 || args[0] == "") {
14
+ usageError()
15
+ exitProcess(1)
16
+ }
17
+ return args[0]
18
19
20
+fun removeWhitespace(phrase: String): String {
21
+ return phrase.filter { !it.isWhitespace() }
22
0 commit comments