laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
f1refly has quit [Ping timeout: 268 seconds]
f1refly has joined #crystal-lang
chemist69 has quit [Ping timeout: 250 seconds]
moei has quit [Ping timeout: 250 seconds]
chemist69 has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
Jenz has joined #crystal-lang
<Jenz>
Moin o/
<Jenz>
DIM = {100, 60}
<Jenz>
Why do I get an error: "invalid constant value" for that?
<Jenz>
Very weird
Jenz has quit [Quit: leaving]
<FromGitter>
<bew> Where/how do you use it?
crystal-lang564 has joined #crystal-lang
ashirase has quit [Ping timeout: 246 seconds]
ashirase has joined #crystal-lang
DTZUZU has quit [Ping timeout: 268 seconds]
DTZUZO has quit [Ping timeout: 268 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
DTZUZU has joined #crystal-lang
DTZUZO has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
crystal-lang564 has quit [Ping timeout: 258 seconds]
<FromGitter>
<apahl> Hi, I am working through "Programming Crystal" by Ivo Balbaert and Simon St. Laurent and I have a question about including modules vs. subclassing. Please keep in mind that I do not come from a Ruby background... ⏎ What is the advantage of implementing `Comparable` as a module in the stdlib and including it in a class where I want to use it vs. implementing it as a class and then subclassing it?
<FromGitter>
<j8r> you're telling essentially composition vs inheritance?
<FromGitter>
<apahl> Yes, probably. For the example of `Comparable` what is the advantage of implementing it via composition?
<FromGitter>
<j8r> yes: you can include it to a struct, a class or another module
<FromGitter>
<j8r> and, you can include multiple module. With inheritance, you can only inherit once and that's it
<FromGitter>
<apahl> Ok, so it can be more versatilly applied that way?
<FromGitter>
<apahl> Thanks for the explanation!
<FromGitter>
<j8r> Yes, it's more flexible
<FromGitter>
<j8r> behind this choice there is also a logic behind: it wouldn't make sense to have a `Comparable` class that can be used as-is. It's a set of methods that can be included ans used in other structs/classes
<FromGitter>
<apahl> Ok, I understand. Thanks again for the explanation, that helped a lot.
<FromGitter>
<j8r> you're welcome :)
crystal-lang564 has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter>
<codenoid> how do i json.parse with a structs ?
laaron has joined #crystal-lang
ternarysolo has joined #crystal-lang
<FromGitter>
<vladfaust> `Struct.from_json("{}")`
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter>
<jwoertink> Mainly for running a spec where the first spec sets up some variables on the instance, then the second spec already knows of these variables
<FromGitter>
<j8r> You want to change a constant?
<FromGitter>
<j8r> you can use `class_property instance`
<FromGitter>
<jwoertink> Yeah, sort of .... I just want to reset the values of `INSTANCE` between specs
<FromGitter>
<jwoertink> but the pattern works fine in the code
<FromGitter>
<j8r> you can instantiate a new class Thing for each
<FromGitter>
<j8r> each spec should be independent of each other, they can be ran separately
<FromGitter>
<jwoertink> I'm not sure I follow, but let me make a quick example
<FromGitter>
<j8r> you should be able to run each `it "should be ... " do ... end` independently, with `crystal spec spec/myfile.cr:12`
<FromGitter>
<jwoertink> that's what I was thinking of doing. I was curious of other's solutions
<FromGitter>
<j8r> I'm afraid not :(
moei has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
crystal-lang564 has quit [Ping timeout: 258 seconds]
<FromGitter>
<kinxer> @jwoertink Soon I'm going to refactor the code I have that uses a singleton, but to reset it in specs I reopen it in the spec_helper, kind of like so: https://play.crystal-lang.org/#/r/6iwa
<FromGitter>
<jwoertink> Yeah, that makes sense. Thanks @kinxer
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
crystal-lang564 has joined #crystal-lang
<FromGitter>
<jwoertink> When using `Spec.before_each`, is there a way to scope it to just the describe block you're in?
<FromGitter>
<vladfaust> Nope
<FromGitter>
<jwoertink> fair enough. Thanks!
<FromGitter>
<kinxer> I don't think so. I think you have to redefine it to an empty method at the end of the block.
ternarysolo has quit [Ping timeout: 246 seconds]
<FromGitter>
<vladfaust> It literally runs before each spec in you compiled specs
<FromGitter>
<vladfaust> However, if you split the specs...
<FromGitter>
<vladfaust> And run each in separate call...
<FromGitter>
<kinxer> That's a sad state of affairs.
<FromGitter>
<vladfaust> Absolutely
<FromGitter>
<jwoertink> Yeah. I put it in one file that I wanted it to run, then ran `crystal spec/` and expected it to only work on that file I added it in
<FromGitter>
<kinxer> Speaking of things that (probably) don't exist, is there a way to use macros in comments?
<FromGitter>
<jwoertink> Yeah, you can just do `{% %}` in a comment