Carrascado
08/01/2020, 3:43 PMTime
class with more than 59 minutes, or more than 59 seconds, it automatically gets adjustedRaphael Ndonga
08/02/2020, 11:43 AMspicyspiders
08/03/2020, 8:52 AMreturn Triple((adults > 0 ? adults : null), (children > 0 ? children : null), (infants > 0 ? infants : null))
Dan O'Brien
08/05/2020, 12:22 AMCarrascado
08/05/2020, 5:06 PMMattias Flodin
08/06/2020, 5:37 PMinterface Source<out T> {
fun nextT(): T
}
fun demo(strs: Source<String>) {
val objects: Source<Any> = strs // This is OK, since T is an out-parameter
// ...
}
If I replace String by a type argument T, it no longer compiles and says "Type mismatch: inferred type is Source<T> but Source<Any> was expected". Why is that? I had expected it work just like in the example.blue
08/07/2020, 5:18 AMhuehnerlady
08/07/2020, 5:49 AMDaniele B
08/07/2020, 11:22 AMDaniele B
08/07/2020, 11:24 AMSudhir Singh Khanger
08/08/2020, 11:11 AMprivate val someTopLevelFunction = SomeClass.Builder().build()
object SomeObject { val someObjectVariable by lazy { someTopLevelFunction().someMethod(someParam) } }
The other option is to use companion object.
interface SomeInterface {
companion object {
fun someTopLevelFunction() = SomeClass.Builder().build()
}
}
These would be called as SomeObject.someObjectVariable()
and SomeInterface.someTopLevelFunction()
. As far as I understand top-level functions they can be accessed directly from anywhere which may pollute auto-completion. But if they are private then that issue won't happen. At the same time, I am not clear what would be their advantage if they are declared as private. Which one would you prefer? And why?Daniele B
08/08/2020, 4:16 PMenum class ViewTypes {
TODAY,
LAST_7_DAYS,
LAST_14_DAYS,
TOTAL,
}
and I would like to loop through it:
for (viewType in ViewTypes) {
...
}
but it gives me an error:
Classifier 'ViewTypes' does not have a companion object, and thus must be initialized here
Daniele B
08/08/2020, 4:16 PMDaniele B
08/08/2020, 4:18 PMenumValues<ViewTypes>().forEach {
...
}
Daniele B
08/08/2020, 7:01 PMRuckus
08/08/2020, 8:50 PM0xA3u + 0x91u
becomes 0xFFu
)? And the same for subtraction (e.g. 0x34u - 0x51u
becomes 0x00u
).Daniele B
08/08/2020, 9:55 PMmylist.sortedBy{it.quantity}.map {
NewElement(
position = (how to retrieve the index of the element in the sorted list?)
name = it.name,
quantity = it.quantity
)
}
is there any way to retrieve the index of the element?cookiecookiecookie
08/09/2020, 12:11 AMcookiecookiecookie
08/09/2020, 12:11 AMDan O'Brien
08/09/2020, 11:58 PMDaniele B
08/10/2020, 2:04 PMval resp = webservicesAPI.fetchLatest()
resp?.let {
repository.name = resp.name
repository.lastUpdate = resp.lastUpdate
}
Daniele B
08/10/2020, 11:42 PMMiguel
08/11/2020, 1:52 PMabstract class X
data class Y() : X(), Serializable
data class Z() : X(), Serializable
var firstValue: X = Y() -> Type mismatch
var secondValue: X = Z() -> Type mismatch
Is there something I am missing?tseisel
08/11/2020, 4:54 PMreverse.domain.name.myapp.mymodule
), or is it possible to use shorter names such as myapp.mymodule
?tipsy
08/12/2020, 12:44 PMclass MyClass(val arg1: String, val arg2: String? = null)
(making it generate two constructors)Karlo Lozovina
08/12/2020, 8:11 PMvar
variable that's declared outside of an measureNanoTime
block? It doesn't seem to work...Sudhir Singh Khanger
08/13/2020, 4:45 AMDaniele B
08/13/2020, 2:24 PMKarlo Lozovina
08/13/2020, 3:05 PMSlackbot
08/13/2020, 8:42 PMSlackbot
08/13/2020, 8:42 PMnanodeath
08/13/2020, 8:44 PMfold
that's capable of early returnvalidatedFold
?Esa
08/13/2020, 10:31 PM