• cheeser
  • ernimril
  • joed
  • kinabalu
  • lunk
  • ojacobson
  • r0bby
  • ThaDon
  • ricky_clarkson
  • topriddy

« 2019-01-09


2019-01-11 »

Nick Message Date
DTZUZO [DTZUZO!] has joined #kotlin [12:48]
thana greves: the correct way is to make sure it's initialized in the constructor... class Foo{val i: Int; constructor(){i = 2;}} [01:06]
Metamelvin [Metamelvin!~Metamelvi@2a02:8070:d19a:3200:c2ee:fbff:fe59:d81e] has joined #kotlin [01:08]
Melvin [Melvin!] has joined #kotlin [01:08]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [01:14]
Metamelvin [Metamelvin!] has joined #kotlin [01:45]
Melvin [Melvin!] has joined #kotlin [01:49]
Metamelvin [Metamelvin!] has joined #kotlin [02:06]
Tazmain [Tazmain!~Tazmain@unaffiliated/tazmain] has joined #kotlin [02:10]
Metamelvin [Metamelvin!] has joined #kotlin [02:11]
Pitel [Pitel!] has joined #kotlin [02:27]
greves thana: but that only works for 'var' not 'val', right? [02:34]
thana greves: nope [02:34]
thana it's perfectly valid to initalizes `val`s in the constrcutor(s) [02:35]
greves thana: I see an error "val on secondary constructor parameter is not allowed" when i try that [02:37]
thana greves: you may write something like `class Foo(val value: String)` but not `class Foo{ constructor(val value: String) }` [02:38]
thana using the primary constructor you can declare fields of the class but that's not allowed with secondar ctors [02:39]
greves OK, that's what I thought but it seemed you said differently [02:39]
greves So, in a secondary constructor I can only initialize "var" and not "val"? [02:39]
greves I mean, I need: class Foo(..) { constructor (x) { this.x = x } } [02:39]
thana so `class Foo(val value:String)` declares a field and you could do `println(Foo("Hello World").value)` [02:40]
greves When I am extending an android View, I need the default constructor, e.g. LinearLayout(context: Context) [02:40]
thana yet `class Foo(value:String)` only declares a constrcutor which expects a string parameter but `Foo("fds").value` does not exist [02:40]
greves I think I need to pastebin exactly what's happening because it's a bit much to type on IRC, just a sec [02:42]
thana yes please :) [02:42]
thana disclaimer: i'm doing kotlin for a week now - my answers might still be wrong or flawed at least [02:42]
ppareit [ppareit!] has joined #kotlin [02:44]
greves Any pastebins for Kotlin? [02:44]
greves [02:45]
thana the people here use hastebin [02:45]
thana so the problem is you NEED a single argument ctor? [02:48]
greves right [02:49]
greves well, it compiles, but it complains about this [02:49]
thana well then you have 2 options i think: either make your val mutable using var an set the value after construction or set some default value [02:50]
thana oh or you can use val with lateinit, yes [02:51]
Ladicek [Ladicek!~lthon@] has joined #kotlin [02:56]
ppareit [ppareit!] has joined #kotlin [04:53]
waz [waz!~waz@pdpc/supporter/active/waz] has joined #kotlin [05:13]
PeterSellers [PeterSellers!~hb2xtv2dt@2a02:a03f:53ef:600:aa40:ccb3:cdfe:e1b4] has joined #kotlin [06:02]
PeterSellers parted the channel: "Leaving" [06:03]
lightslategrey [lightslategrey!~lightslat@] has joined #kotlin [06:17]
t2mkn [t2mkn!~t2mkn@] has joined #kotlin [06:19]
H-K [H-K!] has joined #kotlin [06:32]
cheeser lateinit requires var iirc [08:16]
cheeser greves: can you share your code on a pastebin somewhere? [08:17]
cheeser pastebin [08:17]
cheeser Please paste your code and any errors online. For runnable main-classes, try . For general code and errors, use for instance or [08:17]
OnkelTem [OnkelTem!~onkeltem@unaffiliated/fantomas] has joined #kotlin [08:25]
OnkelTem Hi all [08:25]
OnkelTem I'm new to Kotlin. Passing some tutorials and got some questions [08:26]
OnkelTem class CreatureAdapter(private val creatures: List<Creature>) : RecyclerView.Adapter<CreatureAdapter.ViewHolder>() { [08:26]
OnkelTem What does private here mean? It looks like a parameter to a constructor [08:26]
kapil____ [kapil____!uid36151@gateway/web/] has joined #kotlin [08:26]
OnkelTem Is it? [08:26]
cheeser it means it's a private property on that class. [08:26]
thana it's both: declararing a parameter for the constructor as well as declaring a property of that class (because of the val) [08:27]
OnkelTem But is it used by the constror too? I mean is it a parameter? [08:27]
OnkelTem Ah, I see [08:28]
OnkelTem Pretty optimal then :) [08:28]
thana yep very handy [08:28]
cheeser without var/val, it's just a ctor parameter. with either, it becomes a property. private means there is no access to it outside the class. [08:28]
OnkelTem And about what it extends: "RecyclerView.Adapter<CreatureAdapter.ViewHolder>()" - it looks like an invocation. Is it? Is it something returning a class or... ? [08:29]
OnkelTem cheeser: thanks [08:29]
cheeser the () is necessary because it's a class and you have to invoke a ctor on a parent class. [08:29]
OnkelTem cheeser: what if my derived class didn't have the primary constructor? Had I "call" the baseclass's ctor the same way in this case? [08:37]
OnkelTem I mean: "class CreatureAdapter : RecyclerView.Adapter<CreatureAdapter.ViewHolder>() {" [08:37]
cheeser every class has a primary constructor [08:37]
cheeser if you don't write one, the compiler generates a default, no arg constructor [08:38]
greves cheeser: I did I think earlier [08:38]
greves [08:39]
greves my "Foo" class currently has a lot going on in the primary constructor, but it extends LinearLayout. Probably I should move all of the stuff out of primary constructor and init{}? [08:40]
cheeser you need another constructor for framework to use your type [08:41]
cheeser x will have to be: var x: Something? most likely [08:41]
waz [waz!~waz@pdpc/supporter/active/waz] has joined #kotlin [08:48]
DTZUZO [DTZUZO!] has joined #kotlin [08:50]
greves Ok, got it [08:53]
greves thanks [08:53]
sbalmos [sbalmos!] has joined #kotlin [09:32]
thana coroutines and a js target seem to be a problem yet :( [09:45]
moshen [moshen!~moshen@] has joined #kotlin [10:15]
greggerz [greggerz!~greggerz@unaffiliated/greggerz] has joined #kotlin [10:18]
yawkat [yawkat!~yawkat@] has joined #kotlin [10:42]
moshen [moshen!~moshen@] has joined #kotlin [10:47]
thana the coroutines i create dont seem to even get executed... really sad :( [10:49]
thana does anybody here have expirience with co routines on js? [10:50]
cheeser not me [10:51]
thana cheeser: do you know if there is a channel/list/slack/whatever better suited to place kotlin/js related questions? [11:15]
cheeser there's #coroutins on the kotlin slack [11:17]
thana cool! i'll have a look, thanks [11:18]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [11:46]
funeral [funeral!] has joined #kotlin [11:55]
edge_eng [edge_eng!~edge_eng@unaffiliated/edge-eng/x-8536881] has joined #kotlin [11:57]
computeiro [computeiro!~computeir@] has joined #kotlin [11:58]
t2mkn [t2mkn!~t2mkn@] has joined #kotlin [12:02]
thana too bad. don't get an invite [12:38]
zopsi [zopsi!] has joined #kotlin [12:40]
ppareit [ppareit!] has joined #kotlin [12:55]
vikikas [vikikas!~vikas@2a02:1205:34e1:60b0:2862:d4da:c8a2:f5f4] has joined #kotlin [01:08]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [01:15]
sbalmos [sbalmos!] has joined #kotlin [01:47]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [01:53]
ppareit [ppareit!] has joined #kotlin [01:54]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [02:11]
waz [waz!~waz@pdpc/supporter/active/waz] has joined #kotlin [02:17]
waz [waz!~waz@pdpc/supporter/active/waz] has joined #kotlin [02:29]
ovalseven8 [ovalseven8!~ovalseven@unaffiliated/ovalseven8] has joined #kotlin [03:36]
ovalseven8 Beginner: Should I start with Gradle or Maven? [03:36]
jdlee i prefer maven [03:40]
jdlee \_(?)_/ [03:40]
jdlee YMMV :P [03:40]
Addax jdlee: but answer the question! He's asking if he should use either maven or gradle, and the clear answer, assuming he wants to build a project, esp with a JVM, is "yes." Both of those are far better than the alternatives like make, cmake, ant, buildr, sbt, etc etc etc [03:43]
jdlee haha [03:44]
jdlee ovalseven8: kinda depends on where you're learning. if you're in Androidland, i'd start with gradle, as that's what the official docs show. if you're on Joe Blow's Blog, do as the Romans do. :) [03:47]
ovalseven8 jdlee, I don't do Android programming [03:48]
jdlee nods [03:49]
Addax do you program in a JVM language? [03:49]
ovalseven8 Addax, I want to start with Kotlin [03:49]
jdlee personally, i'd start with Maven. IMO, the ecosystem (and the tool?) seems to be more mature [03:49]
Addax well, are you targeting the JVM? [03:49]
ovalseven8 Addax, Yeah, Kotlin/Native is still beta also [03:50]
ovalseven8 But out of interest: What's the build tool for Kotlin/Native? [03:50]
Addax probably gradle or maven! [03:50]
jdlee haha [03:51]
ovalseven8 Cool [03:51]
Addax From the website on kotlin/native: [03:51]
Addax Addax's title: "Gradle for Kotlin/Native - Kotlin Programming Language" [03:51]
edge_eng [edge_eng!~edge_eng@unaffiliated/edge-eng/x-8536881] has joined #kotlin [04:45]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [04:56]
iam730 [iam730!] has joined #kotlin [05:05]
computeiro [computeiro!~computeir@] has joined #kotlin [05:17]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [06:12]
kerri [kerri!~kerri@april-fools/2014/second/cute.furry] has joined #kotlin [06:53]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [06:55]
jcnmark6 [jcnmark6!] has joined #kotlin [07:06]
waz [waz!~waz@pdpc/supporter/active/waz] has joined #kotlin [07:42]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [08:12]
H-K [H-K!] has joined #kotlin [08:19]
H-K [H-K!] has joined #kotlin [08:21]
theWhisper_ [theWhisper_!~quassel@unaffiliated/thewhisper/x-7482734] has joined #kotlin [09:02]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [09:34]
H-K [H-K!] has joined #kotlin [09:35]
t2mkn [t2mkn!~t2mkn@] has joined #kotlin [09:59]
orbyt_ [orbyt_!~orbyt@] has joined #kotlin [10:22]
ilikecrunch [ilikecrunch!~ilikecrun@] has joined #kotlin [10:48]
waz [waz!~waz@pdpc/supporter/active/waz] has joined #kotlin [11:11]
ppareit [ppareit!] has joined #kotlin [11:16]
kapil____ [kapil____!uid36151@gateway/web/] has joined #kotlin [11:21]
DTZUZO [DTZUZO!] has joined #kotlin [11:24]