<FromGitter>
<revskill10> @Blacksmoke16 ahh, i got it. ⏎ I want to auto json discriminator when subclassing, is it possible ? ⏎ It works fine with `to_json`
<FromGitter>
<revskill10> @Blacksmoke16 it's weird, when i `puts typeof(Event.from_json(new_json)` , it said `Event` instead of `Completed` ?
<FromGitter>
<Blacksmoke16> its not wrong
<FromGitter>
<Blacksmoke16> compiler cant know what specific runtime type will be instantiated based on the JSON, so it says `Event` since they're all children of that type
<FromGitter>
<revskill10> How to check if runtime type is `Completed`
<FromGitter>
<Blacksmoke16> for debugging or?
<FromGitter>
<revskill10> Just a question for runtime version of `typeof` ?
<FromGitter>
<Blacksmoke16> `.class`
<FromGitter>
<revskill10> Thanks ! So much magic in your code. Do you have detail guide on those magics ?
<FromGitter>
<revskill10> One question, what's the idiomatic way for error handling for `from_json` ? Should i create another `safe_from_json` with a rescue (and return Nil)` or let caller do it ?
<FromGitter>
<Blacksmoke16> let the caller do it id say
<FromGitter>
<revskill10> @Blacksmoke16 thanks for the guidance. This JSON part of crystal beats other programming language in a clean way to me ! So clean, safe and DRY !
__ht has joined #crystal-lang
_ht has quit [Ping timeout: 248 seconds]
__ht is now known as _ht
<FromGitter>
<wwalker> I want to include some lua scripts (fairly long) in crystal as a string. But I'd like to have them in separate files, so that I can edit/test them as Lua files. ⏎ ⏎ Is there something like C's #include in crystal?
<FromGitter>
<Blacksmoke16> as strings assigned to a const or?
<FromGitter>
<wwalker> either one. Should likely be a constant, as it will never be modified by crystal
<FromGitter>
<revskill10> @Blacksmoke16 could you help fix this code ? ⏎ https://play.crystal-lang.org/#/r/ei8g ⏎ It's valid Ruby code, just want to port it to Crystal with same semantic.