Johan Alkstål
01/05/2021, 7:12 AMColton Idle
01/05/2021, 1:44 PMval thirty_mins = 30 * 60_000
but there has to be a way to just do TimeUnit.Minutes(30) right?Max Deineko
01/05/2021, 3:10 PMval l = mutableListOf("a")
l[0] = "b"
val x = l.first()
println("""$x=${l.first()}""")
⇒
val l: MutableList<String>
val x: String
a=b
When evaluated with "Use REPL" or via run command from the menu it prints "b=b" instead.
Am I missing something or is this a bug?
(If this is too intellij-specific and not getting-started-related enough, I'll be happy to move this to #intellij)alex cole
01/06/2021, 4:19 AMclass ArrayND {
var nDimensionalArray: ArrayList<Double> = arrayListOf()
private var shape = arrayOf<Int>()
constructor (ndArray: Array<Double>, shape: Array<Int>){
nDimensionalArray = arrayListOf(*ndArray)
this.shape = shape
}
private fun whatIsTheShape(): Array<Int> {
return shape
}
fun add(b: ArrayND): ArrayND {
if (shape.contentEquals(b.whatIsTheShape())){
val x = arrayListOf<Double>()
for(i in 0 until nDimensionalArray.size){
x.add(nDimensionalArray[i] + b.nDimensionalArray[i])
}
return ArrayND(x.toTypedArray(), shape)
}
else {
return ArrayND(arrayOf<Double>(), arrayOf<Int>())
}
}
operator fun plus(other: ArrayND){
add(other)
}
fun print(){
TODO("Work in more than one dimension")
print("[")
for(i in nDimensionalArray) {
print("$i ")
}
print("]")
}
}
huehnerlady
01/06/2021, 7:31 AMUmar Ata
01/06/2021, 7:33 PMChills
01/07/2021, 6:42 AMalex cole
01/09/2021, 12:12 AMval x = object[5,3]
What type of data is the 5, 3 representing.iBehnia
01/09/2021, 7:15 PMalex cole
01/10/2021, 1:54 AMNat Elkins
01/11/2021, 4:03 PMNat Elkins
01/11/2021, 4:25 PMNikhil
01/12/2021, 7:30 AM@IgnoreExtraProperties
in Firestore with an example?Daniele B
01/12/2021, 1:37 PMNat Elkins
01/12/2021, 10:47 PMcall.respond(HttpStatusCode.OK,someJson)
and have the content type be application/json
Grian
01/16/2021, 5:34 PMalex cole
01/17/2021, 2:59 AMclass ArrayND { // the class that I want to type
var elements: Array<Double> // the array that all my functions refer too.
var shape: Array<Int>
constructor (ndArray: Array<Double>, shape: Array<Int>) {
elements = ndArray
this.shape = shape
}
operator fun plus(other: ArrayND): ArrayND {}
operator fun plus(other: Double): ArrayND {}
}
I have a lot of functions that use array lists and convert them .toTypedArray()
to create ArrayND()
. This also has caused a problem when trying to be able to type the array and I would like to know if there is a way that if no type is given I could give it a default type of Double
?Scott Whitman
01/17/2021, 4:21 PMaddress
function below? What are some good practices to handle the Address.Builder
dependency?
fun main() {
val address = address {
street = "123 Any St."
city = "Any city"
}
println(address)
}
fun address(lambda: Address.Builder.() -> Unit): Address {
return Address.Builder().apply(lambda).build()
}
data class Address(
val street: String,
val city: String
) {
class Builder {
var street: String? = null
var city: String? = null
fun build(): Address {
return Address(street!!, city!!)
}
}
}
Stefán Freyr Stefánsson
01/19/2021, 1:14 PMNat Elkins
01/21/2021, 3:32 PMColton Idle
01/21/2021, 7:04 PMclass Blah {
companion object {
//HERE
}
fun somemethod2(){
//THERE
}
}
How can I define a variable that can be used in "HERE" and "THERE"?
I know I can define val MY_CONST
to the top of the file (outside of class declaration) but doesn't that make it global to all my classes? I just want it in the scope of the companion and the class.Lqncer
01/21/2021, 9:08 PMDaniele Segato
01/22/2021, 10:13 AMCoroutineScope
/ CoroutineContext
?
I would I unit test this function?
fun createCoroutineScope(): CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
So in my test I have to check if the returned CoroutineScope
is using a SupervisedJob
or a particular Dispatcher
how do I do that??
(or any other property of the context/scope)Jesus Ochoa
01/22/2021, 1:26 PMvineethraj49
01/24/2021, 10:00 PMval foo
get() = expensiveOrAllocFunc()
vs
val foo by lazy { expensiveOrAllocFunc() }
Wasim
01/25/2021, 9:58 AMF0X
01/25/2021, 7:42 PMallan.conda
01/26/2021, 7:46 AMcheckedSet.contains(value) && checkedSet.size == 1
?alex cole
01/27/2021, 11:23 PMT: Number
and another value in the class is initialized as 0 but that type of Number. How do I do that?
class Complex<T: Number> {
var real: T
var imaginary: T
constructor (real: T) {
this.real = real
imaginary = 0.ofType(T) // this is where help is needed
}
constructor (real: T, imaginary: T) {
this.real = real
this.imaginary = imaginary
}
}
vineethraj49
01/28/2021, 8:08 PM