Mike
01/16/2019, 12:49 PMprintln
What am I missing? I would have expected the val to require an initial value, and complain if it’s assigned, but it appears not.Dalinar
01/26/2019, 9:24 AM@PluginFactory
. Log4j will parse the configuration
// and call this factory method to construct an appender instance with
// the configured attributes.
@PluginFactory
public static AnsiConsoleAppender createAppender(
@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("otherAttribute") String otherAttribute) {
if (name == null) {
LOGGER.error("No name provided for AnsiConsoleAppenderImpl");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new AnsiConsoleAppender(name, filter, layout, true);
}
}ursus
01/30/2019, 3:17 AMMarc Knaup
01/30/2019, 9:12 AMmutableMapOf()
and toMutableMap()
which use LinkedHashMap
or instead hashMapOf()
and HashMap(other)
?Dalinar
02/01/2019, 6:06 AMfun <T> future(context: CoroutineContext = CommonPool, block: suspend () -> T): CompletableFuture<T> =
CompletableFutureCoroutine<T>(context).also { block.startCoroutine(completion = it) }
class CompletableFutureCoroutine<T>(override val context: CoroutineContext) : CompletableFuture<T>(), Continuation<T> {
override fun resumeWith(result: Result<T>) {
result
.onSuccess { complete(it) }
.onFailure { completeExceptionally(it) }
}
}
suspend fun <T> CompletableFuture<T>.await(): T =
suspendCoroutine { cont: Continuation<T> ->
whenComplete { result, exception ->
if (exception == null) // the future has been completed normally
cont.resume(result)
else // the future has completed with an exception
cont.resumeWithException(exception)
}
}
I mean, is it correct apart from the CommonPool
part? should I just replace CommonPool
with EmptyCoroutineContext
?ursus
02/05/2019, 4:35 AMinterface ReadFooRepository {
fun getFoos() : List<Foo>
}
class FooRepository : ReadFooRepository {
override fun getFoos() ...
fun saveFoo(foo: Foo) ...
}
@provides @singleton fooRepository() : FooRepository = FooRepository()
@provides readFooRepository(fooRepository: FooRepository) : ReadFooRepository = fooRepository
class FooViewModel(private val readFooRepository : ReadFooRepository)
... only consume values
vpriscan
02/10/2019, 8:00 PMval esClient: RestHighLevelClient by lazy {
createEsClient(
hosts = arrayOf(HttpHost("localhost", 9200, "http"))
)
}
pajatopmr
02/11/2019, 4:47 AMmersan
02/12/2019, 12:40 AMmersan
02/12/2019, 12:44 AMrook
02/15/2019, 3:04 PMsitepodmatt
02/20/2019, 2:47 AMbreandan
02/21/2019, 3:03 PMrook
02/22/2019, 5:19 PMinvoke()
inlined or otherwise achieve what I’m attempting in doWork()
?elect
03/03/2019, 6:53 PMprotected fun prepareStandardSemaphores(device: VulkanDevice): ConcurrentHashMap<StandardSemaphores, VkSemaphore_Array> {
val map = ConcurrentHashMap<StandardSemaphores, VkSemaphore_Array>()
StandardSemaphores.values().forEach {
map[it] = VkSemaphore_Array(swapchain.images.size) {
vkDev.createSemaphore(semaphoreCreateInfo)
}
}
return map
}
chansek
03/04/2019, 7:47 PMarekolek
03/06/2019, 9:25 AMfun foo(bar: List<Int>): Int {
check(bar.isNotEmpty())
return bar.max()!! / 2
}
How would you deal with max
returning a nullable value, other than !!
? Does it bother you?sitepodmatt
03/06/2019, 9:26 AModay
03/15/2019, 4:51 PMtenprint
03/16/2019, 2:42 PMsharedElements?.let { thisSharedElements ->
names?.let { thisNames ->
viewHolder?.let { thisViewHolder ->
thisSharedElements[thisNames[0]] = thisViewHolder.itemView
}
}
}
gjesse
04/08/2019, 3:31 PMfun <T> T?.orElse(default: T) = this ?: default
for example i have a when statement like this
return when {
foo.blah?.someNullableFlag ?: false -> true
}
vs
return when {
foo.blah?.someNullableFlag.orElse(false) -> true
}
snowe
04/09/2019, 8:25 PMincomeTypes.forEach {
val incomeType = IncomeType.valueOf(it, IncomeType.UNKNOWN)
Dominaezzz
04/28/2019, 1:32 PMList<T>
or Array<T>
?elect
05/13/2019, 8:50 PM// Request several formats, the first found will be used
for (request in requestFormats)
for (avail in availFormat)
if (avail.format == request && avail.colorSpace == requestColorSpace)
return avail
// If none of the requested image formats could be found, use the first available
return availFormat[0]
arekolek
05/14/2019, 12:06 PMPeriodType.Past
for example, but if everything is the same, enum should be fineaddamsson
05/20/2019, 7:42 PMelect
05/27/2019, 2:15 PMint insertionIndex = 0;
for (insertionIndex = 0; insertionIndex < activeActionSetsList.Count; insertionIndex++) {
if (activeActionSetsList[insertionIndex].nPriority > activeSet.nPriority)
break;
}
Dominaezzz
06/06/2019, 7:29 PMMap<K, V>.putIfAbsent(key: K, value: V)
? putAll
overrides existing values sadly.elect
06/13/2019, 8:10 AMDoBlendRoutine
as a suspend function and blendRoutine
as a Job?
, however I'm not sure about the StartCoroutine
part.. I think I shall directly launch { }
at that pointDominaezzz
06/15/2019, 4:03 PM\n
.
val text = "some te\nxt about stuff\nshort"
text.split('\n').map { it.length }.max() // 14
Can I do this without creating new string objects and still be functional?