Andrew Gazelka
01/07/2019, 1:56 AMrajkumar
01/07/2019, 5:35 AMkarelpeeters
01/07/2019, 9:15 AM-
operator.APXEOLOG
01/07/2019, 1:41 PMval properties = mutableListOf<Property>()
inline fun <reified T : Property> getProperty(): T? {
return properties.filter { it::class == T::class }.firstOrNull() as T?
}
I don't like this as T?
part, but if i remove it i will receive error:
Type inference failed. Required: T?, found: Property?
Am i doing something wrong?LeoColman
01/07/2019, 4:01 PMdewildte
01/07/2019, 4:28 PMadam-mcneilly
01/07/2019, 4:42 PMvar myString: String by SharedPrefsString(myPrefs)
but I wanna use my SharedPrefsString type in Java, if possible.Slackbot
01/07/2019, 4:48 PMkarelpeeters
01/07/2019, 7:12 PMhashcode()
? Can you give an example?xenoterracide
01/08/2019, 12:42 AMException in thread "main" java.lang.NoSuchMethodException: com.potrero.Application.main([Ljava.lang.String;)
at java.base/java.lang.Class.getDeclaredMethod(Class.java:2476)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
package com.potrero
import org.apache.logging.log4j.LogManager
import org.springframework.beans.factory.getBeanProvider
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.info.BuildProperties
import org.springframework.boot.runApplication
@SpringBootApplication
open class Application
fun main(args: Array<String>) {
val ctx = runApplication<Application>(*args)
ctx.getBeanProvider<BuildProperties>().ifAvailable {
LogManager.getLogger(Application::class.java).info("Starting {}", it.artifact)
}
}
shouldn’t this kotlin class work to start spring boot?Marcin Wisniowski
01/08/2019, 9:29 AMdamian
01/08/2019, 2:05 PMfun SamplingEvent.DataEvent.SensorArrayValuesEvent.toSensorDataString(): String {
var segment = ""
for (i in 0..(sensorCount - 1)) {
segment += "$timestampNanos,${sensorType[i]},${values0[i]},${values1[i]},${values2[i]},${values3[i]},${values4[i]},${values5[i]}\n"
}
return segment.dropLast(1)
}
My first instinct is to lift this out of extension function and use/reuse StringBuilder (with sufficient initial buffer) ?mbonnin
01/08/2019, 2:27 PMfirst=1 (int)
but I thought kotlin has no implicit conversions.mbonnin
01/08/2019, 2:29 PMList listOfDouble = CollectionsKt.listOf(1.0D);
if (listOfDouble == null) {
throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.List<kotlin.Int>");
} else {
int first = ((Number)listOfDouble.get(0)).intValue();
System.out.println("first=" + first + " (" + Integer.TYPE.getName() + ')');
}
Richard Green
01/08/2019, 2:40 PMAndrew Gazelka
01/08/2019, 5:40 PMinit{}
occur after init and if so, is it a good practice if order matters to include it in init{}
?
i.e.,
class Logger(val logFile: Path)
{
val writer = Files.newBufferedWriter(logFile)
init {
if(!Files.exists(logFile))
{
Files.createFile(logFile)
}
}
}
Andrew Gazelka
01/08/2019, 5:42 PM.field
equivalent in Kotlin for constructors? I can't seem to find one, and it is really annoying to manually create the property definition...Jannis
01/08/2019, 7:26 PMDALDEI
01/09/2019, 1:40 AMmyanmarking
01/09/2019, 3:25 PMdimsuz
01/09/2019, 4:04 PMval
?
I use DI framework and it finds primitive boolean
here:
class MyPresenter @Inject constructor(val field: Boolean)
and fails to generate injector.
One way is to use val field: java.lang.Boolean
, but it feels a bit dirty and generates a warningdavidkarlsen
01/09/2019, 6:20 PM@Bean
@ConditionalOnProperty( prefix = "proxy", name = "enabled", havingValue = "true")
public RestTemplateCustomizer restTemplateCustomizer() {
return restTemplate -> {
var proxy = new HttpHost(host, port, scheme);
var httpClient = HttpClientBuilder.create().setRoutePlanner(new DefaultProxyRoutePlanner(proxy)).build();
restTemplate.setRequestFactory( new HttpComponentsClientHttpRequestFactory(httpClient));
};
}
where RestTemplateCustomizer is a functional interface.
But I have trouble writing this in KotlinValV
01/09/2019, 8:20 PM/path/to/file
), than store it as a String
? Better way to split it later by directories (path
, to
, file
)?snowe
01/09/2019, 9:28 PMCannot access class 'kotlinx.serialization.KSerialLoader'. Check your module classpath for missing or conflicting dependencies
? I’ve followed the directions in the kotlinx readme.Bernardo Ferrari
01/10/2019, 1:58 AMserebit
01/10/2019, 4:15 AMclass ReactMap : MutableMap<Long, MutableList<EmoteData>> by (mutableMapOf<Long, MutableList<EmoteData>>()
.withDefault { mutableListOf<EmoteData>() })
compiles fine, and
class ReactMap : MutableMap<Long, MutableList<EmoteData>> by mutableMapOf()
compiles fine, but
class ReactMap : MutableMap<Long, MutableList<EmoteData>> by (mutableMapOf().withDefault { mutableListOf() })
doesn't? Is it a bug in the compiler, or is it intentional?fkrauthan
01/10/2019, 5:45 AMtest: KClass<Any>
how can I fix the problem that when for example passing in MyClass::class
the type missmatch error?Andrew Gazelka
01/10/2019, 10:58 AMopen class A(val a: String, val b: String = "hello")
class B(a: String, b: String, c: String) : A(a, b) {
}
in this scenario would it be possible to have b
arg in class B
have default value "hello"
while being DRY?Andrew Gazelka
01/10/2019, 11:00 AMRunnable
can be called with () -> Unit
but when the type is Runnable...
?, () -> Unit
cannot be called?Andrew Gazelka
01/10/2019, 11:35 AMout
keywordAndrew Gazelka
01/10/2019, 11:35 AMout
keywordkarelpeeters
01/10/2019, 11:58 AMBackGroundAction.() -> Unit
is not a subtype of PeriodicAction.() -> Unit
.(Int) -> Unit
and (Any) -> Unit
Andrew Gazelka
01/10/2019, 12:01 PMtodd.ginsberg
01/10/2019, 2:19 PMAndrew Gazelka
01/10/2019, 7:05 PMtodd.ginsberg
01/10/2019, 7:44 PM