louiscad
08/29/2019, 1:21 PMUse New J2K (experimental)
settings flag in the IDE after using the search feature with the "J2K" words.
Has the actual setting been forgotten to be added/enabled for use?Marcin Wiśniewski
08/29/2019, 6:45 PMGreg Stepniewski
08/30/2019, 7:57 AMIf a coroutine encounters exception other than CancellationException, it cancels its parent with that exception. This behaviour cannot be overridden and is used to provide stable coroutines hierarchies for structured concurrency.However, you have SupervisorJob which says
A failure or cancellation of a child does not cause the supervisor job to fail and does not affect its other children.These two seem to contradict, since SupervisorJob clearly overrides the behaviour of children cancelling their parent on failure - or am I missing something?
svenjacobs
08/30/2019, 8:26 AMclass A {
fun String.hello() = "hello $this"
}
Is there any simpler solution of calling this function instead of having to use with()
?
val a = A()
"Some string".run {
with(a) { hello() }
}
Czar
08/30/2019, 11:34 AMval entity = repository.getOne(entityId)
val entityId = checkNotNull(entity.id) { "Entity id cannot be null if it is retrieved from the database" }
all over the place. In the new project first we thought of using contracts, but their restrictions make them useless for this case, so this more crude idea was born:
abstract class BaseEntity<T : Serializable> {
/**
* Direct use of `_dbId` is strongly discouraged in business level code, this should only be used on the persistence
* level by the framework and related infrastructure code.
*/
@Suppress("PropertyName")
protected abstract val _dbId: T?
/**
* Accessing `id` implies that entity has been retrieved from a repository or crafted with a pre-set identifier.
* If this condition is not met, accessing it will generate an `IllegalStateException`.
*/
@get:Transient
val id: T
get() = checkNotNull(_dbId) { "Entity has not been saved" }
}
Any thoughts? Improvements? Maybe better alternatives?
In this here case, implementation would look like:
@Entity(name = "clients")
class InfoEntity(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
override val _dbId: Long? = null,
@Column(name = "first_name")
var info: String = ""
) : BaseEntity<Long>()
Konstantin Petrukhnov
08/30/2019, 11:46 AMLastExceed
08/30/2019, 12:35 PMsuspend
. is that a sign of bad code or is this normal? i've read somewhere that at least in C# "async everything" is pretty common but im not sure if that applies to kotlin as wellEugen Martynov
08/30/2019, 1:12 PMEugen Martynov
08/30/2019, 1:13 PMsealed class Operation(val value: Int) { class Add()...class Divide()}
or class Operation(val type:Type, val value: Int)
where Type
is enum?halirutan
08/30/2019, 3:10 PMmain
fun with the examples provided in the problems?Nikky
08/30/2019, 7:50 PMThis property is marked as @Transient and therefore must have an initializing expressionseems like this is no longer valid?
@Transient
lateinit var rootDir: File
this seems to only be a error on 1.3.50, worked fine on 1.3.41Shawn
08/30/2019, 11:41 PMassociate { }
function that I’m missing? I’m trying to build a map and have multiple keys associated with the objects I’m iterating over - currently I’ve got something like this:
entries.flatMap { entry ->
(entry.aliases + entry.name).map { it to entry }
}.toMap()
which probably isn’t the most efficient approach 😬Mehdi
08/31/2019, 8:48 AMKroppeb
08/31/2019, 3:56 PMpython
import socket
IP = "127.0.0.1"
PORT = 25565
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_STREAM)
sock.bind((IP, PORT))
sock.listen(1)
conn, addr = sock.accept()
try:
while True:
data = conn.recv(1024)
if not data: break
print(*(hex(i)[2:].rjust(2,'0') for i in data))
finally:
conn.close()
but I can't seem to find an easy solution in kotlinKroppeb
08/31/2019, 9:53 PMclass Handshake (val ProtocolVersion : Int,
val ServerAdress : String,
val port : UShort,
val NextState : Int): Packet{
override suspend fun sendData(channel: WriteByteChannel) {
channel.write {
varInt(ProtocolVersion)
string(ServerAdress)
uShort(port)
varInt(NextState)
}
}
companion object {
fun parse(channel: ReadByteChannel) = Handshake(
ProtocolVersion = channel.readVarInt(),
ServerAdress = channel.readString(255),
port = channel.readUShort(),
NextState = channel.readVarInt()
)
}
}
LastExceed
09/01/2019, 7:38 AMclass Human(val name: String, age: Int) {
var age = age
private set
fun birthday() {
//party hard
age++
}
}
can this be simplified somehow or is it good as is?Kroppeb
09/01/2019, 10:41 AMclass enum<T:Types<R>, R>(Name: String) : Types<R>(Name)
but is it possible to have the following
val p = enum<varInt>("NextState"))
// instead of
val p = enum<varInt, Int>("NextState"))
// varInt
class varInt(Name: String) : Types<Int>(Name)
rrader
09/01/2019, 4:49 PM"X-Secret"::equalsIgnoreCase
?Eugen Martynov
09/02/2019, 5:42 AMlateinit var
for things that should be downloaded first. Is it good practice? (I don’t like it)LastExceed
09/02/2019, 6:24 AMfun main() {
val x = Thing(42)
when(x) {
Thing(42) -> {
println("foo")
}
else -> {
println("bar")
}
}
}
inline class Thing(val value: Int)
the output is foo
IntelliJ suggests inlining x
, like so:
fun main() {
when(val x = Thing(42)) {
Thing(42) -> {
println("foo")
}
else -> {
println("bar")
}
}
}
inline class Thing(val value: Int)
however now it outputs bar
. why is that?yen
09/02/2019, 12:46 PMBernhard
09/02/2019, 2:04 PMval list: List<Pair<String, String>> = listOf(
"a" to null,
"b" to "hi"
)
.filter {it.second != null}
ushort
09/02/2019, 3:49 PMndv
09/02/2019, 4:25 PMprivate fun copyFonts () {
val fontsFolder = File(javaClass.getResource("../../fonts").file)
val fontsOutput = File(options.fontOutputLocation)
if (!fontsOutput.exists()) fontsOutput.mkdir()
fontsFolder.copyRecursively(fontsOutput, overwrite = true) { file, exception ->
throw IllegalStateException("Could not copy file ${file.absolutePath}. ${exception.message}")
}
}
However, the .otf files seem to get corrupted somehow during the copy. I've tried manually converting each file to a byte array and creating files manually, same problem.
In a nutshell, the files in the original /fonts folder are around 90kB, once they've been copied over they are about 150kB and LaTeX no longer recognizes the file. If I manually copy the original font files over to the output folder, LaTeX compilation goes back to working normally.
I just recently updated from Kotlin 1.3.31 to 1.3.50 - which is when the problem started.
Any suggestions? Thank you!
EDIT:
Just tried by calling robocopy
from inside Kotlin - same problem.
However, calling robocopy from powershell copies the files correctly
Also: my .otf files seem to be the only ones affected by this.pp.amorim
09/02/2019, 6:01 PMstring?.let { //... }
, if I remove this I get this warning (waiting upload...)pp.amorim
09/02/2019, 6:01 PMAlessandro Tagliapietra
09/02/2019, 7:36 PMreturn new Processor() {...
?josephivie
09/02/2019, 9:42 PMOleh Ponomarenko
09/03/2019, 12:55 PMit as ImageButton
it.rotateSmoothly()
Like this:
(ImageButton) it.rotateSmoothly();
pawel.rybicki
09/03/2019, 3:55 PMpawel.rybicki
09/03/2019, 3:55 PMMarko Mitic
09/03/2019, 3:56 PMsetText
, allowedUrls won't be initialized in timeEugen Martynov
09/03/2019, 3:57 PMwasyl
09/03/2019, 3:58 PMCasey Brooks
09/03/2019, 3:58 PMTextView
base class:
public TextView(
Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
// TextView is important by default, unless app developer overrode attribute.
if (getImportantForAutofill() == IMPORTANT_FOR_AUTOFILL_AUTO) {
setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_YES);
}
setTextInternal(""); <-- THIS IS THE CRASH
streetsofboston
09/03/2019, 3:59 PMpawel.rybicki
09/03/2019, 4:01 PMwasyl
09/03/2019, 4:12 PMsetTextInternal
, but there’s another setText
call in the constructor. But maybe it’s only there on certain Android versions?pawel.rybicki
09/03/2019, 4:22 PMCasey Brooks
09/03/2019, 4:31 PM?.let
call, it might be that the initial textViewMessage
is null in the majority of casespawel.rybicki
09/03/2019, 4:35 PM