Florian
06/27/2019, 9:29 AMCamilleBC
06/27/2019, 10:33 AMfun getData(): Data?
-> catch all exceptions and return null
- fun getData(): Data
-> throw
exceptions depending on the situation and have the user of the library catch them
- fun getData(): Outcome<S: Success, F: Failure>
-> create a custom class to wrap the result
I'm very much a beginner, and I have no clue what would be the best pratice.
Btw I'm using retrofit2
with kotlin's coroutines, so the REST requests might return exceptions.pavel
06/27/2019, 2:23 PMtoString
. Now I am doing some log manipulation and need to go from that String representation to the data class itself. Is there a simple way to do that?Edward
06/29/2019, 9:13 PMkarelpeeters
06/30/2019, 6:07 PMNikita
07/01/2019, 3:50 PMpoohbar
07/02/2019, 7:07 PMlist.filter { it.field != null }
.associateBy({ it.id }, { it.field!! })
is there a way to avoid !!
on the second line?
list
is a list of:
data class Person(val id: String, val field: Field?)
Slackbot
07/03/2019, 6:15 PMVadim Kotov
07/04/2019, 8:32 AMMike R
07/05/2019, 5:30 PMmy_obj.__dir__
Florian
07/06/2019, 5:56 PMin
is the same as contains
. What is the operator function for in
when we use it in a loop?Florian
07/07/2019, 4:33 PMQuinn
07/08/2019, 1:33 PM{
"api.test": [],
"<http://apps.permissions.info|apps.permissions.info>": [
"token"
],
"apps.permissions.request": [
"token",
"scopes",
"trigger_id"
],
So in the end I could call my method with myApp.api.test('Bearer s0met0ken') and myApp.apps.permissions.request('Bearer s0met0ken', 'user.write', 'aTrigger')
Is this possible with some functional magic?Florian
07/08/2019, 8:16 PMFlorian
07/08/2019, 8:51 PMIve Vasiljevic
07/09/2019, 12:15 PMwith
inline function has a receiver and another function that behaves as extension function, so that receiver is able to execute that function on it self. My question is how does that inline function accept multiple lines of code that need to be executed?Hullaballoonatic
07/09/2019, 10:34 PMursus
07/10/2019, 1:31 AMursus
07/10/2019, 1:32 AMDiogo Ribeiro
07/10/2019, 8:21 AMtipsy
07/10/2019, 2:38 PMusually({
}, sometimes {
})
is it possible to get rid of the parens for usually
somehow, so i just get:
usually {
} sometimes {
}
?poohbar
07/11/2019, 2:18 PMassociateBy
that would throw if a key should have more than one value?karelpeeters
07/12/2019, 10:49 AMb00m
07/12/2019, 12:38 PMjosh
07/12/2019, 3:01 PMFlorian
07/12/2019, 5:34 PMtest1.equals(test2)
does?Florian
07/13/2019, 10:05 AMequals
it compares the pointer by default, correct?b00m
07/13/2019, 1:27 PMscottiedog45
07/14/2019, 1:52 AM.count
lambda inside this function; it looks to me like a lambda is being passed to an Int
? What?
fun bingo(ticket: Array<Pair<String, Int>>, win: Int) =
if (ticket.count { it.second.toChar() in it.first } >= win) "Winner!" else "Loser!"
I’m on https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/count.html and don’t see anything like a closure happening for Array.count
CoopCoding
07/14/2019, 1:55 AMfun main() {
val strings = listOf("Hello", "World", "!")
val getLengthOfString = fun(str: String) : Int {
return str.length
}
val lengths = strings.map(getLengthOfString)
println(lengths)
}
But if the function is a regular function, I cant pass in the function name like so:
fun main() {
val strings = listOf("Hello", "World", "!")
fun getLengthOfString(str: String): Int {
return str.length
}
val lengths = strings.map(getLengthOfString)
println(lengths)
}
CoopCoding
07/14/2019, 1:55 AMfun main() {
val strings = listOf("Hello", "World", "!")
val getLengthOfString = fun(str: String) : Int {
return str.length
}
val lengths = strings.map(getLengthOfString)
println(lengths)
}
But if the function is a regular function, I cant pass in the function name like so:
fun main() {
val strings = listOf("Hello", "World", "!")
fun getLengthOfString(str: String): Int {
return str.length
}
val lengths = strings.map(getLengthOfString)
println(lengths)
}
leodeng
07/14/2019, 4:05 AM::getLengthOfString
CoopCoding
07/14/2019, 4:15 AMb00m
07/14/2019, 4:42 AMAl Warren
07/14/2019, 5:33 AMCoopCoding
07/14/2019, 5:48 AM::
basically used to satisfy the types?
Also, in most other languages, ::
means bind, is that not the case here?
Thanks.Shawn
07/14/2019, 2:19 PM::
Foo::bar
. Since the function exists within the local scope, there isn’t a name to really qualify its location by, so it comes out to just ::bar
.::
is used probably because reusing .
is ambiguousCoopCoding
07/14/2019, 10:03 PMAl Warren
07/14/2019, 10:20 PMShawn
07/14/2019, 10:24 PM::
isn’t like bind or otherwise like plus
or other infix operators - in this case it would fall in the same category as the dot operator or even ->
in C