Daniel
06/05/2021, 7:56 PMLastExceed
06/06/2021, 3:45 PMdata class
be open
?Prateek Tiwari
06/07/2021, 4:23 AMJavier
06/07/2021, 10:23 AMRanjan Rukhaya
06/07/2021, 10:42 AMFanilog
06/07/2021, 6:05 PMRemoteUser
received by a backend to a User
object used by the business logic inside an app)? I used to do it via Interface + Implementation
interface IUserMapper {
fun remoteToEntity(remote: RemoteUser): User
}
, what is the real benefit than doing it directly with an extension function ?
fun RemoteUser.toUser() =
...
(except mocking) 🤔y9san9
06/07/2021, 6:13 PMvalues
)
The set impl: https://pastebin.com/zfHS0KZc (used in the map keys
, entities
)
I hope there is a proper solution, and you can say what I'm doing wrong (or maybe this is the only way)Peter
06/07/2021, 6:29 PMinline fun <reified T>test() { typeOf<T>()... }
magnumrocha
06/08/2021, 11:03 AMkotlin.Result
class?Stephan Schroeder
06/08/2021, 12:44 PMNorbert Sziráczki
06/08/2021, 2:16 PMViet Nguyen Tran
06/08/2021, 3:39 PMglenkpeterson
06/08/2021, 8:58 PMval file = File("hello.txt")
return when {
file.isFile -> Or.good(file)
else -> Or.bad(chapter.fileName)
}
But if I try to capture the when
subject in a variable like this:
return when(val file = File("hello.txt")) {
file.isFile -> Or.good(file)
else -> Or.bad(chapter.fileName)
}
I get, "Incompatible Types: Boolean and File" on the file.isFile
part?
The end of this section makes it look like I should be able to do this: https://kotlinlang.org/docs/control-flow.html#when-expressionjean-paul
06/09/2021, 9:07 AMSlackbot
06/09/2021, 9:58 AMBig Chungus
06/09/2021, 10:01 PMFung.Yam
06/10/2021, 8:52 AMpackage private
with sealed and protected?Saiedmomen
06/10/2021, 11:41 AMrequireNotNull
does not provide smart cast null safety. Is there another way to concisely mark null as Illegal state and have smart cast?
private var id: Long? = null
override fun delete() = runBlocking {
requireNotNull(id)
notesRepository.deleteNote(id!!) // id is not smart cast to not null
}
Piotr Krzemiński
06/10/2021, 11:47 AMErik
06/10/2021, 2:25 PMCh8n
06/10/2021, 7:01 PMPatrick Ramsey
06/10/2021, 8:52 PMuli
06/11/2021, 6:54 AMByteArray
with hex literals. Here is my Approach:
val key = intArrayOf(0x80, 0xFF, 0x00, 0x7f).map { it.toByte() }.toByteArray()
And the result is (and should be):
-128,-1,0,127
Is there a more compact/idiomatic way to do that?LastExceed
06/11/2021, 8:25 AMUserProfile
class email
and about_me
are different types ? I know its overkill but i cant help itMitch
06/11/2021, 8:45 AMDominaezzz
06/11/2021, 11:51 AM(1..5).size
?blakelee
06/11/2021, 7:42 PMval x = 370.1
x + 0.1
I'm getting 370.20000000000005 on a few different Kotlin versionsSlackbot
06/11/2021, 8:28 PMglenkpeterson
06/11/2021, 11:12 PM// Error here ---v
fun <T : Slugged & BaseModel> suggestSlug(
tempSlug: String,
clazz: Class<T>,
): String
I want to make sure the class passed to this function implements Slugged
(to be sure it has a .slug
property) and extends the abstract class BaseModel
(to be sure it has an .id
property and is a database @Entity
class - I'm using Ebean).
I found this, which shows the set-theory, but doesn't show the syntax I need (I apologize if I am misunderstanding any of this):
https://kotlinlang.org/spec/type-system.html#intersection-types
Should I just make an abstract SluggedBaseModel
? I'd rather not because abstract vars annotated @Column
need to be initialized and this should be a non-null required constructor parameter for each entity bean that uses it.TheDukerChip
06/12/2021, 6:49 AMTheDukerChip
06/12/2021, 6:49 AMKirill Grouchnikov
06/12/2021, 7:30 AMTheDukerChip
06/12/2021, 7:38 AMKirill Grouchnikov
06/12/2021, 8:26 AMTheDukerChip
06/12/2021, 9:49 AMStephan Schroeder
06/14/2021, 6:12 AM