https://kotlinlang.org logo
#codereview
Title
# codereview
a

alex cole

01/10/2021, 1:36 AM
What name should I use instead of
toNumber()
for the following code to follow the kotlin style guide.
Copy code
class ArrayND {
    var data: ArrayList<Double> = {...}
    var shape: Array<Int> = {...}

    operator fun get(vararg indicies: Int): ArrayND {...}

    fun toNumber(): Double {
        if (data.size == 1) {
            return data[0]
        } else {
            Throw Error
        }
    }
}
1
e

ephemient

01/10/2021, 1:40 AM
Copy code
fun single() = data.single()
3
a

alex cole

01/10/2021, 1:42 AM
Thank you.
2 Views