ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
fifr has quit [*.net *.split]
straight-shoota has quit [*.net *.split]
lanodan has quit [*.net *.split]
Liothen has quit [*.net *.split]
olbat__ has quit [*.net *.split]
lanodan has joined #crystal-lang
Liothen has joined #crystal-lang
lanodan is now known as Guest9073
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
fifr has joined #crystal-lang
straight-shoota has joined #crystal-lang
guniberas has joined #crystal-lang
postmodern has joined #crystal-lang
postmodern has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
ur5us has quit [Quit: Leaving]
petoem has joined #crystal-lang
guniberas has quit [Ping timeout: 245 seconds]
Starfoxxes has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
Starfoxxes has joined #crystal-lang
Guest9073 has quit [Quit: WeeChat 3.3]
lanodan has joined #crystal-lang
casionaut has joined #crystal-lang
casionaut has quit [Quit: o7]
guniberas has joined #crystal-lang
<FromGitter> <christopherzimmerman> I feel like I'm missing something very obvious: https://play.crystal-lang.org/#/r/c64t. Any ideas why Crystal thinks I'm not initializing this variable?
<FromGitter> <Blacksmoke16> you're using `self.`
<FromGitter> <Blacksmoke16> compiler usually doesnt like when you use `self` in an initializer as it thinks that ivar could be used before its initialized
<FromGitter> <Blacksmoke16> kinda silly that removing it in this context works, maybe its something that could be improved?
<FromGitter> <christopherzimmerman> Yea, that's confusing, especially since the error doesn't indicate anything related to that, but thanks, that fixes it.
<FromGitter> <Blacksmoke16> 👍
hightower2 has joined #crystal-lang
taupiqueur has joined #crystal-lang
casionaut has joined #crystal-lang
hightower2 has quit [Ping timeout: 268 seconds]
sagax has quit [Ping timeout: 264 seconds]
sagax has joined #crystal-lang
<FromGitter> <skojin> Hi, I'm trying to create Hash with default block, but it not work for Int64, what's wrong? https://play.crystal-lang.org/#/r/c63v
<FromGitter> <Blacksmoke16> i think the issue is that you're passing `1` which is an `Int32` to a hash that is keyed as `Int64`. Thus the default block isn't called since the missing key isn't valid when compared to the key of the hash
<FromGitter> <Blacksmoke16> i.e.g `pp hash64[1_i64]` works fine
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/9565 prob related
casionaut has left #crystal-lang [o7]
<frojnd> I have JSON::Any and would like to get different properties
<frojnd> this is json_data in my case
<frojnd> When I try to serialize like this: `meditation = MeditationJson.from_json json_data` I get: `Error: no overload matches 'JSON::Lexer.new' with type JSON::Any`
<FromGitter> <Blacksmoke16> pass `from_json` the raw string, not `JSON::Any`
<frojnd> Well if I pass the raw string I get: `Error: no overload matches 'JSON::Lexer.new' with type (Float64 | Int64 | Slice(UInt8) | String | Nil)`
<FromGitter> <Blacksmoke16> 🤔
<frojnd> Wait
<frojnd> I had to pass it with to_s `meditation = MeditationJson.from_json json_string.to_s`
<frojnd> Not sure why?
<FromGitter> <Blacksmoke16> what is `json_string`?
<FromGitter> <Blacksmoke16> its apparently a union of diff types, hence that error
<frojnd> @BlackSmoke16 json_string has also array of Strings inside. Maybe this is the reason?
<FromGitter> <Blacksmoke16> prob not
<FromGitter> <Blacksmoke16> like where does that string come from/get set?
<frojnd> It gets from sqlite3 DB
<FromGitter> <Blacksmoke16> via `.read`?
<frojnd> `db.scalar "SELECT json_extract(meditation, '$') FROM dailymeditation WHERE DATE == DATE('#{date}')"`
<FromGitter> <Blacksmoke16> throw a `.as(String)` on the end of it
<FromGitter> <Blacksmoke16> also you should use prepared statements versus `#{date}`
<FromGitter> <Blacksmoke16> `db.scalar("SELECT json_extract(meditation, '$') FROM dailymeditation WHERE DATE == DATE(?)", date ).as(String)`, something likethis
guniberas has quit [Ping timeout: 268 seconds]
<frojnd> I get the prepared statements but why add .as(String) because this is not actually a string in that step?
<FromGitter> <Blacksmoke16> because the db driver doesnt know what type the scalar value is, so it returns a union of all the possible types
<FromGitter> <Blacksmoke16> in your context you *know* its going to be a string, so can tell it as such
<frojnd> Oh thank you this was very helpful
taupiqueur has quit [Quit: taupiqueur]
<frojnd> I created a cli app. Now I would like to call this app or some function from another web app.
<frojnd> What are my options?
<FromGitter> <Blacksmoke16> you *could* ofc do a system call to call that binary from the webapp. But would probably be better to re-couple your logic so you can use the same methods/types in both contexts
<FromGitter> <Blacksmoke16> de-couple*
hightower2 has joined #crystal-lang
avane has quit [Ping timeout: 260 seconds]
ur5us_ has joined #crystal-lang
ur5us_ has quit [Remote host closed the connection]
avane has joined #crystal-lang
hightower2 has quit [Ping timeout: 264 seconds]
maxpowa has quit [Ping timeout: 265 seconds]