<FromGitter>
<Blacksmoke16> it can only be a string
laaron has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> 1 -- when I started using crystal a variable had a type and stuck to it. When you wanted a non-nil value, you reassigned it. When did it change? ⏎ 2 -- how to create a variable whose type is *actually* `String | Nil` for testing purposes?
<FromGitter>
<dscottboggs_gitlab> oh well at least I have something that works with consistency
<FromGitter>
<Blacksmoke16> well in that case yea, it can only ever be a string
<FromGitter>
<dscottboggs_gitlab> but I've restricted the type to `String | Nil`
<FromGitter>
<Blacksmoke16> that that var could take
<FromGitter>
<Blacksmoke16> not what it currently is
<FromGitter>
<dscottboggs_gitlab> like I expect that when I declare a variable as `String?` that on some level it's a `String | Nil` union. Idk
<FromGitter>
<dscottboggs_gitlab> specs pass
<FromGitter>
<Blacksmoke16> but its not a union, its a limitation of the types a var could hold, it would be a union of the possible types it *could*be was string or nil
<FromGitter>
<Blacksmoke16> but in this case it can only ever be a string so thats its type
<FromGitter>
<dscottboggs_gitlab> but I want to be able to declare a variable of a particular type and have it stick? Like that seems like it should be a basic feature
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<dscottboggs_gitlab> idk it's probably just a side-effect of trying to not have the compiler take up GB of memory trying to instantiate everything as unions of any type available
<FromGitter>
<Blacksmoke16> ye prob
<FromGitter>
<Blacksmoke16> could just do what i did tho, `var = "string" || nil || 1` etc
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<dscottboggs_gitlab> yeah that's what I did
<FromGitter>
<dscottboggs_gitlab> but that really seems like a hack to me... like "string" is truthy, so it can't ever get past that point
<FromGitter>
<Blacksmoke16> dunno
alexherbo2508 has joined #crystal-lang
<FromGitter>
<Blacksmoke16> now, any ideas on how to pass an empty tuple as a generic type? :P
<FromGitter>
<dscottboggs_gitlab> like what if they decide to optimize that away in a few versions?
<FromGitter>
<Blacksmoke16> trying to splat from a tuple, so if tuple has args it breaks thinking its going to new up a class with args it doesnt need
<FromGitter>
<dscottboggs_gitlab> could you just...not specify a type?
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<Blacksmoke16> `wrong number of type vars for Athena::DI::ServiceDefinition(ServiceKlass, AnnotationArgs, ServiceArgs) (given 1, expected 3)`
<FromGitter>
<dscottboggs_gitlab> could you give some context? also I'm kinda tired and you might get a better answer out of me in the morning
<FromGitter>
<Blacksmoke16> this has proved to be quite a challenging problem
<FromGitter>
<dscottboggs_gitlab> indeed. From what I've heard, DI usually is
<FromGitter>
<dscottboggs_gitlab> especially for statically-typed systems
<FromGitter>
<Blacksmoke16> tell me about it :p
<FromGitter>
<dscottboggs_gitlab> heh
* FromGitter
* dscottboggs_gitlab is hitting the hay ✌️
<FromGitter>
<Blacksmoke16> third time refactoring this, getting closer i feel
<FromGitter>
<Blacksmoke16> o/ night
<FromGitter>
<Blacksmoke16> nope, looks like the tuple from doesnt work when the array is a union with another array
<FromGitter>
<Blacksmoke16> well no, its thinking there is a type union within my clas
_whitelogger has joined #crystal-lang
<FromGitter>
<watzon> I need something that's the opposite of `File.expand_path`. I want to just get the part of the path that's different, or return `nil` if the path doesn't match at all.
<FromGitter>
<watzon> So `File.method("/documentation/button", "/documentation")` should just return `"/documentation"`
<FromGitter>
<watzon> Does that exist? Or will I need to write it myself? I'm not finding anything.
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 246 seconds]
<FromGitter>
<watzon> Also, is anyone else having trouble signing in to https://crystal-ann.com on Firefox?
<FromGitter>
<watzon> I'm getting a `SSL_ERROR_INTERNAL_ERROR_ALERT` error
<FromGitter>
<watzon> Just happened on Chrome too actually
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<bew> @watzon why do you want a File method, you can just do `"/foo/bar".delete("/foo")` and get `"/bar" `
<FromGitter>
<watzon> Lol my brain wasn't working. I guess that would work. It doesn't account for the possibility of `/foo/bar` having a trailing slash, but I don't think that's an issue in my case.
ashirase has quit [Ping timeout: 258 seconds]
ashirase has joined #crystal-lang
devil_tux has quit [Ping timeout: 258 seconds]
<FromGitter>
<r00ster91> @watzon same with Firefox. It works with Edge though
DTZUZO has quit [Ping timeout: 244 seconds]
laaron- has joined #crystal-lang
<FromGitter>
<watzon> Big surprise, Edge let's security issues slide lol
laaron has quit [Ping timeout: 256 seconds]
alexherbo25086 has joined #crystal-lang
alexherbo2508 has quit [Ping timeout: 255 seconds]
<FromGitter>
<dscottboggs_gitlab> I can't do a `self.new` either... which makes sense
<FromGitter>
<dscottboggs_gitlab> I guess I could just name that method something different
JuanMiguel has joined #crystal-lang
<FromGitter>
<pynixwang> new is class method
<FromGitter>
<dscottboggs_gitlab> mmhmm
<FromGitter>
<pynixwang> `key = nil` and remove first `initialize`
<FromGitter>
<dscottboggs_gitlab> and the rest of it doesn't work anyway. I'll have to come back to it later ✌️
<FromGitter>
<dscottboggs_gitlab> no key can't be nil
<FromGitter>
<mwlang> Are there any examples of more complex use cases for HTTP::Client? For example, if I want to do anything like Faraday's middleware to inject additional parameters into REQUESTs....in the case of communicating with Binance API, some endpoints are public and some must be signed. The signed endpoints in the Ruby gem implements Faraday Middleware like this: ⏎ ⏎ ```code paste, see link```
<FromGitter>
<pynixwang> method args need some effort.
<FromGitter>
<Blacksmoke16> if im newing up a class with an IO like `File.open("path.log")`, do i have to explicitly close the io, or does that get handled for me at some point?
<FromGitter>
<pynixwang> block may close for you
<FromGitter>
<Blacksmoke16> but if im not using a block
<FromGitter>
<pynixwang> or a gc finalize hook?
<FromGitter>
<Blacksmoke16> could work
<FromGitter>
<pynixwang> no try
<FromGitter>
<Blacksmoke16> but what would happen if it never gets GC?
<FromGitter>
<Blacksmoke16> i.e. short lived program or something
<FromGitter>
<pynixwang> os will close for you when program exit
<FromGitter>
<pynixwang> maybe
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<pynixwang> 。。
<FromGitter>
<pynixwang> emmmm?
<FromGitter>
<Blacksmoke16> ill just go with it for now
<FromGitter>
<bararchy> Will that break Fiber but wont effect the block outside ?
<FromGitter>
<bararchy> I just want to stop the execution of the Fiber
<FromGitter>
<pynixwang> you can spawn a fun
notdaniel has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
<FromGitter>
<mwlang> @bararchy Check out this play from @z64 yesterday...He showed me how to break out of a loop in a spawned block and continue to do stuff in the main loop: https://play.crystal-lang.org/#/r/6xlw
<FromGitter>
<mwlang> in your case, something like ```break if condition``` would be the line to get you out of the block you spawned.