ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
<FromGitter> <mattrberry> I have cases where it's useful to have an enum of a larger UInt32 type even if it only represents numbers up to 31
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <Blacksmoke16> if you dont customize the values could you do something with just the amount of constants?
<FromGitter> <mattrberry> `sizeof(MyEnum)` just returns the size of the underlying int type, right? Can you call that in a macro anyway?
<FromGitter> <Blacksmoke16> idt
<FromGitter> <mattrberry> Yeah that was my first thought, but I have a few cases like this :/ ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <Blacksmoke16> rip
<FromGitter> <mattrberry> If I could just do a `while` loop or have a `break` in my macro, I'd be set haha
<FromGitter> <mattrberry> Ooh can I return early from a macro? I'm guessing not?
<FromGitter> <Blacksmoke16> dont think so
<FromGitter> <Blacksmoke16> would love if someone got a PoC working for that. would be *sooo* helpful
<FromGitter> <mattrberry> The first issue you sent gave me an idea
<FromGitter> <mattrberry> ```code paste, see link``` []
<FromGitter> <mattrberry> I hate it but it works lol
<FromGitter> <mattrberry> Also, that syntax for macros is new to me. I didn't realize that was valid. Makes writing macros a lot shorter..
ur5us has joined #crystal-lang
<FromGitter> <mattrberry> lol... ⏎ ⏎ ```code paste, see link``` []
<FromGitter> <mattrberry> Just increments off of the last value I guess..
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 255 seconds]
Sankalp has quit [Ping timeout: 268 seconds]
Sankalp- has joined #crystal-lang
Sankalp- is now known as Sankalp
<FromGitter> <azurelmao> Sankalp: Ok, so the reason why was returning (Bar | Nil) was because of the unless statement. This snippet works:
kiwiroy has quit [Ping timeout: 268 seconds]
kiwiroy has joined #crystal-lang
<FromGitter> <Blacksmoke16> i feel like there's a better way to do what you're doing
<FromGitter> <Blacksmoke16> @azurelmao is the goal to just have a singleton type that's lazily initialized?
<Sankalp> @azurelmao cool, you can even lose the `return`s
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ tada? []
<Sankalp> @Blacksmoke16 it gives error while trying to access `bar`
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ fixed []
<Sankalp> Works now!
<FromGitter> <Blacksmoke16> 👍
_ht has joined #crystal-lang
hightower2 has joined #crystal-lang
hightower2 has quit [Remote host closed the connection]
<FromGitter> <azurelmao> Wow, this is much cleaner!
<FromGitter> <azurelmao> Thanks!
<FromGitter> <Blacksmoke16> np
_ht has quit [Quit: _ht]
<FromGitter> <azurelmao> Is there a cleaner way to do this? Preferably so that I can just plop Player as the first argument and not *this*
<FromGitter> <Blacksmoke16> can you not have it just accept `Player`?
<FromGitter> <Blacksmoke16> and not a proc
<FromGitter> <azurelmao> Nah I can't. I want to be able to create multiple vars, which would require the the instance var to be generic smth like Class and that isn't possible
<FromGitter> <azurelmao>
ur5us has joined #crystal-lang
<FromGitter> <Blacksmoke16> no i mean an instance of `Player`
<FromGitter> <Blacksmoke16> tada?
tsujp_ has joined #crystal-lang
fifr has joined #crystal-lang
jrayhawk_ has joined #crystal-lang
jhass- has joined #crystal-lang
jhass has quit [Ping timeout: 244 seconds]
tsujp has quit [Ping timeout: 244 seconds]
dom96 has quit [Ping timeout: 244 seconds]
jrayhawk has quit [Ping timeout: 244 seconds]
acoolstraw has quit [Ping timeout: 244 seconds]
mikko has quit [Ping timeout: 244 seconds]
fifr_ has quit [Ping timeout: 244 seconds]
jhass- is now known as jhass
tsujp_ is now known as tsujp
dom96 has joined #crystal-lang
mikko has joined #crystal-lang
mikko has quit [Changing host]
mikko has joined #crystal-lang
jrayhawk_ is now known as jrayhawk