Anyone can help me to link this test: A ```class R...
# getting-started
p
Anyone can help me to link this test: A
Copy code
class Rectangle {
    val width: Int
    val length: Int

    constructor(_width: Int, _length: Int) {
        width = _width
        length = _length
    }
}

val rectangle = Rectangle()
B
Copy code
class Rectangle {
    val width: Int
    val length: Int

    constructor(width: Int, length: Int) {
        width = width
        length = length
    }
}
C
Copy code
class Rectangle {
    val width: Int
    val length: Int
    
    constructor(_width: Int, _length: Int) {
        width = _width
        length = _length
    }

    constructor(_sizeA: Int, _sizeB: Int) {
        width = _sizeA
        length = _sizeB
    }
}
D
Copy code
class Rectangle {
    val width: Int
    val length: Int

    constructor(width: Int, length: Int) {
        
    }
}
E
Copy code
class Rectangle {
    val width: Int = 1
    val length: Int = 1

    constructor(width: Int, length: Int) {
        this.width = width
        this.length = length
    }
}
F
Copy code
class Rectangle() {
    var width: Int = 1
    var length: Int = 1

    constructor(width: Int, length: Int) {
        this.width = width
        this.length = length
    }
}
I am a bit confused 🧐 1. Signature uniqueness violation 2. Primary constructor call is absent 3. Reassigning previously 4. Uninitialized properties 5. No values passed for constructor pararmeters 6. Reassigning val because of name collision
v
Why don't you just try it, for example on play.kotl.in? Should be A - 5 B - 6 C - 1 D - 4 E - 3 F - 2
t
I know that's a technical test to grasp the syntax, but I don't understand the point of this question ... every Kotlin developer would have written
class Rectangle(val width: Int, val length: Int)
v
Probably to gather insight. Test questions are seldomly related to real code.
p
@Vampire thanks for the answer, I didnt know I could run this code in play.kotl. Again, thanks!
v
But better understand why the pairs are like they are 😉
p
Definitely, I am into it.
👌 1