nfrankel
01/10/2019, 12:47 PMmvn package -DskipTests
trying mvn package -Dskip
without success
😞jeggy
01/10/2019, 3:23 PMclass Outer(var value: String = "") {
inner class Inner {
var id = 0
val str: String get() = value + id
}
}
fun main(args: Array<String>) {
fun Outer.Inner.update() = also { value = "Hello World" } // I don't have access to `value` here :(
println(Outer().Inner().update().str)
}
Dalinar
01/10/2019, 4:05 PMfun
how can I make a static import for it in Java?kz
01/10/2019, 4:37 PMkarelpeeters
01/10/2019, 7:11 PMamanda.hinchman-dominguez
01/10/2019, 7:37 PMxenoterracide
01/10/2019, 8:19 PMsean
01/10/2019, 9:36 PMxenoterracide
01/10/2019, 10:46 PMExpected size:<2> but was:<1> in:
<[fun <init>(kotlin.String, kotlin.String, kotlin.String, java.time.Instant, kotlin.String, kotlin.String): com.potrero.ph.emr.entity.Emr]>
at com.potrero.ph.emr.entity.EmrTest.new(EmrTest.kt:12)
paxi
01/11/2019, 2:30 AMrunBlocking { var a = 1; var b = 2; a + b; }
piece of code.
I understand this is https://youtrack.jetbrains.com/issue/KT-28007, but must I include -din=0
part?Bernhard
01/11/2019, 12:29 PMnickk
01/11/2019, 1:40 PMBernhard
01/11/2019, 3:57 PMlistOfObjects
.filter { it.field != null }
.map { it.field.method() }
Shawn
01/11/2019, 7:41 PMrobstoll
01/11/2019, 8:03 PMfoo<Int, String>(1, 2) { "result: $it" }
foo(1, 2)<String>{ "result: $it" }
The first one has less surprises but is more verbose than the second. Thoughts?Jainil Patel
01/12/2019, 2:16 AMjmfayard
01/12/2019, 10:36 AMcontract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
yodgor777
01/12/2019, 2:35 PMSlackbot
01/12/2019, 3:50 PMhmole
01/12/2019, 6:19 PMVishnu Haridas
01/12/2019, 8:41 PMalso
when I wrote the code 😄 So I thought of sharing it so that others will find the fun and enjoy it.cbruegg
01/13/2019, 10:54 AMDico
01/13/2019, 9:00 PMfun maxSubarraySum(list: List<Int>, n: Int): Int? {
if (list.isEmpty()) return null
return (0..list.size - n).map { i -> list.subList(i, i + n).sum() }.max()
}
Alan Evans
01/13/2019, 9:54 PMfun List<Int>.maxSubListSum(n: Int) =
take(n)
.sum()
.let { sum ->
drop(n)
.foldIndexed(sum to sum) { i, (sum, max), next ->
(sum + next - this[i]).let {
it to if (it > max) it else max
}
}.second
}
(Sorry for no thread).rnett
01/14/2019, 2:41 AMclass Builder<T extends Builder<T>>
. In java, you just use new SpaceToBatchLayer.Builder()
, however, Kotlin forces you to specify the type argument. Is there a way around this for interop w/ java?Alexjok
01/14/2019, 7:49 AMthana
01/14/2019, 11:15 AMLong
when they are initialized with 0
but i cannot find documentation for this behavior. furthermore it is not applied when the code is compiled in to javascript. any help on this?hudsonb
01/14/2019, 7:25 PMdo
is a Java keywordDico
01/14/2019, 11:43 PMConsumer {}
xenoterracide
01/15/2019, 2:58 PMval bis = from.buffered()
var b : ByteArray = byteArrayOf()
while ( ( bis.read(b) ) != -1 ) {
}
is there a better way to read in bytes in kotlin (yes the file is binary)xenoterracide
01/15/2019, 2:58 PMval bis = from.buffered()
var b : ByteArray = byteArrayOf()
while ( ( bis.read(b) ) != -1 ) {
}
is there a better way to read in bytes in kotlin (yes the file is binary)hho
01/15/2019, 3:00 PMxenoterracide
01/15/2019, 3:01 PMAlan Evans
01/15/2019, 3:04 PMread
xenoterracide
01/15/2019, 3:11 PMvar bytes = ByteArray(72)
var read = 0
while ( ( read = bis.read(bytes) ) != -1 ) {
for (byte in bytes) {
addByte( byte )
}
}
kotlin doesn't like the assignment thereAlan Evans
01/15/2019, 3:12 PMxenoterracide
01/15/2019, 3:12 PMAlan Evans
01/15/2019, 3:13 PMval b = ByteArray(4096)
do {
val read = bis.read(b, 0, b.size)
if (read == -1) break
// you got "read" bytes in buffer
} while (true)
do while
is the cleanest way I know ofwhile(true)
is ickyxenoterracide
01/15/2019, 3:17 PMAlan Evans
01/15/2019, 3:18 PMfun InputStream.readInBlocks(blockSize: Int = 4096, function: (ByteArray, Int) -> Unit) {
val buffer = ByteArray(blockSize)
do {
val count = read(buffer, 0, blockSize)
if (count == -1) break
function(buffer, count)
} while (true)
}
Usage:
bis.readInBlocks { buffer, count ->
// you got "count" bytes in buffer
}
xenoterracide
01/15/2019, 3:20 PMAlan Evans
01/15/2019, 3:21 PMinline fun
as that would save a lot of function calls over 256GB of small blocks.xenoterracide
01/15/2019, 3:26 PMAlan Evans
01/15/2019, 3:36 PMprivate fun
.
Remember you can always move later, and I think it's best to keep visibility of anything, class, function or property, to the minimum you need.pp.amorim
01/17/2019, 12:27 PMxenoterracide
01/17/2019, 4:48 PM