I'm new to kotlin. I've got a problem with making a function that changes the value of the boolean.
fun main () {
    var x = false
    functionWithBoolean(variable = x)
}
fun functionWithBoolean(variable: Boolean) {
    if (variable){
        println("x is true, so I switch to false")
        variable = false //value of x should be changed from true to false
    }
    else if (variable == false){
        println("x is false, so I switch to true")
        variable = true //value of x should be changed from false to true
    }
}
The error I encountered: Kotlin: Val cannot be reassigned
Please for explanation how to make "variable" var, altough x is set for var.
 
     
     
     
     
    