Ask coding questions

← Back to all posts
Why is this simple if block failing in Repl but runs on all other IDE's ?
phmenard (0)

/ begin code
val age = 15

if (age <= 12) {
println("Child")
} else if (age >= 13 && age <= 17) {
println("Teenager")
} else {
println("Adult")
}
/ end code

I'm running through a Lambda pre-course and I can't get this to work.
Here is the error generated.

error: expecting '}'
if (age <= 12) {
^

Child
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^
error: unexpected symbol
} else if (age >= 13 && age <= 17) {
^

Teenager
error: unexpected symbol
} else {
^
error: unexpected symbol
} else {
^
error: unexpected symbol
} else {
^

Adult
error: unexpected symbol
}
^

Commentshotnewtop
phmenard (0)

Something I forgot to mention above I'm using Kotlin