Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<anicholson> @Blacksmoke16 it's still both because the union of all possible return types from `One#get` is still `(Int32|Nil)`
<FromGitter>
<Blacksmoke16> yea, naturally i see that soon as i post it here
<FromGitter>
<anicholson> :)
<FromGitter>
<Blacksmoke16> was trying to handle nil check in parent, so that in child classes the ivars will be not nil for sure, but couldnt come up with a good solution
<FromGitter>
<anicholson> well as long as you have a fallback `Int32` value for when `super` does return `nil`, then that's still possible
<FromGitter>
<Blacksmoke16> bit more complex in my actual app
<FromGitter>
<Blacksmoke16> as i need to return 2 values
<FromGitter>
<Blacksmoke16> and cant default them :/
return0e has joined #crystal-lang
return0xe has quit [Ping timeout: 240 seconds]
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
<FromGitter>
<anicholson> if you don't have a fallback value, then the `Int32?` type would seem to be correct - you may be able to push the nil resolution further downstream.
zorp_ has joined #crystal-lang
<FromGitter>
<Blacksmoke16> basic i have a few classes that all have a `valid?` method
<FromGitter>
<Blacksmoke16> that inherit from a parent class, where all of them should return nil if a value is nil
<FromGitter>
<anicholson> is there a reason you want to return no value?
<FromGitter>
<Blacksmoke16> well that just returns nil
<FromGitter>
<Blacksmoke16> which im using as a third "neutral" value
<FromGitter>
<anicholson> > which im using as a third "neutral" value ⏎ ⏎ that's a bit of a smell to me...
<FromGitter>
<anicholson> so there's 3 values: valid, invalid, and unknown?
<FromGitter>
<Blacksmoke16> pretty much
<FromGitter>
<Blacksmoke16> like say the assertion is value is greater than 10
<FromGitter>
<Blacksmoke16> if the value is 11 its valid
<FromGitter>
<Blacksmoke16> if its 9 its invalid
<FromGitter>
<Blacksmoke16> if its nil, then its unknown, which in this case is still a valid value since there wasn't a NotNil check
<FromGitter>
<Blacksmoke16> as you werent explicitly checking if it wasnt nil
<FromGitter>
<anicholson> so when I see a predicate method, I expect it to follow boolean rules, ie. have two return values.
<FromGitter>
<anicholson> so either `nil` is value, and you should actually return `true`, or it's not, and you shouild return `false`.
<FromGitter>
<anicholson> If you need to postpone that decision until later, then I don't think there's a good reason to try to remove the `nil` check in the first place
<FromGitter>
<Blacksmoke16> yea...not sure im happy with my current implementation of this, have to think about it for a bit, but for now is prob fine
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<anicholson> you're kind of describing a type with 3 values: valid, invalid & unsure. You could create wrapper objects for each of those states and pass the wrapped value through your chain of validators
<FromGitter>
<Blacksmoke16> thats an option, have to think about it
_whitelogger has joined #crystal-lang
<FromGitter>
<leolanavo_gitlab> I'm sorry if this doubt is too basic for this chat. What is the "default" ORM for building a Crystal API, is it Crecto or some other one?
<FromGitter>
<Blacksmoke16> Granite, Crecto, Jennifer are all popular choices
<FromGitter>
<Blacksmoke16> @leolanavo_gitlab
<FromGitter>
<Blacksmoke16> best to read up on the docs of each/ask questions/ play around with each to find best fit
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
zorp_ has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<jhass>
anyone got their 35C3 tickets already? Are we enough for an assembly? :D
zorp_ has joined #crystal-lang
zorp_ has quit [Ping timeout: 250 seconds]
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<proyb6> What do you guys this about Mint language?
<FromGitter>
<proyb6> I wonder why someone want to burn Crystal?
<FromGitter>
<proyb6> When I feel this is a nice way to develop web app fast
return0xe has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
<FromGitter>
<pitosalas> Newbie question... what's the typical edit/compile/run sequence of commands? In other words typically do you have an editor open on the .cr file, and then what are you doing in the shell? Or is there a vscode plugin that is better?
<FromGitter>
<aboeglin> @pitosalas what other language are you used to ?
<FromGitter>
<pitosalas> ruby ... a lot
<FromGitter>
<pitosalas> java but through eclipse mostly
<FromGitter>
<aboeglin> oups, I don't know ruby. But mostly you'd use shards to manage dependencies and build
<FromGitter>
<pitosalas> is there a writeup anywhere?
<FromGitter>
<aboeglin> then for running you just need to start the executable, eventually giving it parameters if your program expects any like you would with argc & argv in C.
<FromGitter>
<Blacksmoke16> you sure your class name isnt conflicting with a class in the stdlib?
<FromGitter>
<r00ster91> maybe because you call it "Class"
<FromGitter>
<r00ster91> try "Classs" or something else
<z64>
i don't think they are actually calling it `Class`. anyways, this works fine https://carc.in/#/r/5c4q ; @aboeglin can you provide a runnable example of the error you're encountering?
<FromGitter>
<aboeglin> funnily if I try to reproduce it I can't
<FromGitter>
<aboeglin> I did almost the exact same thing z64
<FromGitter>
<aboeglin> I haven't used Class though, it was to highlight the use of it
<FromGitter>
<aboeglin> that's actually the real "Class" we speak about
<FromGitter>
<aboeglin> if I don't give language_id or user_id I get into trouble
<z64>
ah, okay
<FromGitter>
<Blacksmoke16> well you're just saying they are nilable
<FromGitter>
<Blacksmoke16> you need to provide a default value to use if you dont pass them in
<FromGitter>
<aboeglin> oh, I removed the default values here
<FromGitter>
<aboeglin> but I had them 5mn ago
<FromGitter>
<vladfaust> *x filed theme*
<z64>
lmao
<z64>
to be clear: is it still not working with the defaults correctly provided?
<FromGitter>
<aboeglin> I just got it, somehow I got it mixed up with the union types of the JSON mapping before I think
<FromGitter>
<aboeglin> basically I went nuts because it worked before I add the language_id field, and the user_id has always had a default value before
<FromGitter>
<aboeglin> thanks !
<z64>
ah i see. no problem:)
marmotini_ has joined #crystal-lang
davic has quit [Remote host closed the connection]
davic has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter>
<drum445> Using https and kemal is having loads of these errors build up over time expected?
return0xe has quit [Read error: Connection reset by peer]
marmotini_ has quit [Remote host closed the connection]
<FromGitter>
<ljuti> What’s the best way to trace which spec breaks the test run when the error trace doesn’t give you the file name?
<FromGitter>
<vladfaust> a) Run `spec spec/my_spec.cr` file by file or by dir `spec spec/my_dir/`
<FromGitter>
<vladfaust> b) good ol' `puts`
<FromGitter>
<ljuti> @vladfaust I’m using spec2.cr and I think it’s the suspect somehow …
<FromGitter>
<vladfaust> I better not using spec2
<FromGitter>
<vladfaust> It's bugged as hell
<FromGitter>
<ljuti> Too bad I found that out now the hard way
<FromGitter>
<ljuti> Every spec runs and passes when run individually
<FromGitter>
<ljuti> Well, this really sucks ...
<FromGitter>
<ezrast> @Blacksmoke16 No, `Array(Supertype)` and `Array(Subtype)` don't have any particular relationship even though `Subtype < Supertype`. Do this: https://play.crystal-lang.org/#/r/5c7m
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<straight-shoota> @ljuti I don't know about spec2. But with stdlib spec you can add `-v` cli arg and it prints the names of the specs
<FromGitter>
<ljuti> @straight-shoota I think I found a bug in spec2
<FromGitter>
<ljuti> It’s a shame, it had some nice features from RSpec that makes writing cleaner specs easier
<FromGitter>
<ljuti> I think the language team should consider introducing concepts of `let` and `subject` to `spec`
<FromGitter>
<ljuti> Oh, and `described_class` is a big one
<z64>
having used rspec a good amount, i've never really felt the need for any of those in crystal's Spec. it seems to just complicate things when assigning local variables (that can be shared between tests) and spec helper methods works just as well
<z64>
that said, method stubbing can be cumbersome if your API design doesn't lend itself to be stubbed (i.e., your methods have too much behavior)
<z64>
to an extent too, you can also omit type restrictions on your functions and pass in test objects instead of full types from the rest of your app/library
<FromGitter>
<ljuti> Old habits die hard
<z64>
yep. i found reading crystal's own specs, and specs of the libraries i use to be a good source of inspiration. the nice thing is that static typing - rather the compiler - already greatly reduces the testing "surface area" that you might otherwise have in a ruby application
<FromGitter>
<straight-shoota> +1 z64
<FromGitter>
<straight-shoota> there was a conversation about this a few days ago
<FromGitter>
<straight-shoota> IMHO the reduced features of Crystal `spec` compared to `rspec` are actually an improvement. It enforces specs to be self contained and don't rely on some behaviour defined somewhere outside of it. Makes it much easier to understand the examples.
Jenz has joined #crystal-lang
Jenz has quit [Client Quit]
<FromGitter>
<vladfaust> I agree about Crystal specs being quite sterling
<FromGitter>
<KevinSjoberg> I'm running `Process.run` to grab the output of a given command. However, the output is wrapped with single quotes. Why is this?
<FromGitter>
<KevinSjoberg> I'm using `IO::Memory` for stdout. It correctly grabs all the output including newlines but it's wrapped with single quotes, e.g., `"'some\noutput\nhere'"`
<FromGitter>
<KevinSjoberg> This is very annoying since running `#each_line` on the output give me `'some` as the first line and `'` as the last line.
johndescs has quit [Ping timeout: 244 seconds]
johndescs has joined #crystal-lang
<non-aristotelian>
I remember seeing a page on Github that had a long list of Crystal libraries -- anyone know/have the link available?