If I write a code like this in swift it says variable x used before initialized. This seems legit in java. Why is this not possible in swift and how do I achieve the same?
var x:Int
var y:Int = 0
if (y==0) {
x=0
}
if (y==1) {
x=1
}
y=x