RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
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> <Blacksmoke16> currently just replicating ⏎ ⏎ ``` val = @value ⏎ act = @actual ⏎ return unless val && act``` ⏎ ⏎ in each sub class [https://gitter.im/crystal-lang/crystal?at=5bd11409069fca52a58cb169]
<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> <pitosalas> yeah I don't know what shards are yet. also what commands? Do I have to do --release on a build? Questions like that. I found https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists
<FromGitter> <aboeglin> you have a shard.yml file that describes your targets and dependencies
<FromGitter> <aboeglin> and the shards cli allows you to install these dependencies and build your targets
<FromGitter> <pitosalas> when I run a program with just `crystal prog.cr` can I supply argc?
<FromGitter> <aboeglin> it should yes
<FromGitter> <aboeglin> you have a global array ARGV that should do it
<FromGitter> <aboeglin> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bd1ae4cbbdc0b250599429b]
moei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
moei has quit [Ping timeout: 245 seconds]
rohitpaulk has quit [Ping timeout: 276 seconds]
<FromGitter> <fusillicode_twitter> Hi guys is it possible to have two records that mixes a module defining their common initialization? 🤔
<FromGitter> <fusillicode_twitter> The final goal is to have available the `copy_with` method
<FromGitter> <fusillicode_twitter> Unfortunately it is only available by using the `record` marco
<FromGitter> <fusillicode_twitter> Unfortunately^2 the structs that I actually have shares a common `initialize` method that has a generic type
<FromGitter> <fusillicode_twitter> The initialize method resides in a proper module that I mix inside the two structrs
<FromGitter> <bew> So what's your issue? You can include the module in your 2 records
<FromGitter> <fusillicode_twitter> @bew sure but it seems that the common `initialize` doesn't get `inherited`
<FromGitter> <fusillicode_twitter> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bd1cbde1c100a4f29e10545]
<FromGitter> <fusillicode_twitter> The `initialize` method resides inside the `ProposalFields(String)` module
<FromGitter> <fusillicode_twitter> The compiler tells me that the only initialization method that it find is without any arguments
<FromGitter> <fusillicode_twitter> But the `ProposalFields(String)` defines an `initialize` with a lot of arguments XD
<FromGitter> <bew> Hmm might be easier to do your own record macro
<FromGitter> <fusillicode_twitter> Well yeah but you know, the first rule about macros is "don't use macros" XD
<FromGitter> <fusillicode_twitter> Ok this time a more quick question
<FromGitter> <fusillicode_twitter> mmm
<FromGitter> <fusillicode_twitter> I suppose that what I'm trying to to achieve with this isn't possible https://play.crystal-lang.org/#/r/5c00
<FromGitter> <fusillicode_twitter> :(
zorp_ has joined #crystal-lang
<FromGitter> <bew> What do you expect this to do?
<FromGitter> <r00ster91> @fusillicode_twitter you could do this: ⏎ https://play.crystal-lang.org/#/r/5c18/edit ⏎ or loop through the values of `asd`
<FromGitter> <bew> After `record` comes the struct name and the fields
<FromGitter> <fusillicode_twitter> @r00ster91 uhm thanks this clarify some things 😅
<FromGitter> <fusillicode_twitter> @bew well I was trying to passa a variable list of fields to the macro 😅
<FromGitter> <fusillicode_twitter> not having the copy_with is really an incredible PITA XD
Yxhuvud has joined #crystal-lang
<FromGitter> <bew> you can still add it for you
<FromGitter> <aboeglin> is there any way in initialize to omit a parameter ?
<FromGitter> <Blacksmoke16> if there's a default on it it wouldnt be considered required
<FromGitter> <aboeglin> say if I have: ⏎ ⏎ ```def initialize(@p1 : String, @p2 : String? = nil) ⏎ ... ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5bd1f7c7435c2a518e03b68f]
<FromGitter> <vladfaust> Hey guys, I've updated https://github.com/crystaljobs for your reference, enjoy!
<FromGitter> <aboeglin> If I don't pass p2 it tells me there's no overload that matches
<FromGitter> <Blacksmoke16> what are you passing it?
<FromGitter> <aboeglin> Class.new p1: "some string"
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5c4h ?
<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> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bd1f9561e23486b9318529f]
<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?
<FromGitter> <drum445> doesn't seem to be causing issues but seems odd
return0xe has quit [Read error: Connection reset by peer]
return0xe has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5c71 shouldn't this work since `Int32` is part of the allowed union types?
dostoyevsky has quit [Changing host]
dostoyevsky has joined #crystal-lang
return0e has joined #crystal-lang
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?
<non-aristotelian> Hmm, this looks similar: https://crystal.libhunt.com
<FromGitter> <KevinSjoberg> Oh, @sdzyba a bit faster. :)
<non-aristotelian> Thank-you sdzyba, KevinSjoberg.