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
sorcus has quit [Ping timeout: 258 seconds]
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Ping timeout: 246 seconds]
DTZUZU has joined #crystal-lang
DTZUZU_ has quit [Ping timeout: 260 seconds]
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Ping timeout: 265 seconds]
DTZUZU_ has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
hendursa1 has joined #crystal-lang
hendursaga has quit [Ping timeout: 240 seconds]
lanodan has quit [*.net *.split]
straight-shoota has quit [*.net *.split]
DeBot has quit [*.net *.split]
Liothen has quit [*.net *.split]
DeBot has joined #crystal-lang
lanodan has joined #crystal-lang
Liothen has joined #crystal-lang
straight-shoota has joined #crystal-lang
sorcus has joined #crystal-lang
DTZUZU has quit [Ping timeout: 260 seconds]
DTZUZU has joined #crystal-lang
sorcus has quit [Quit: WeeChat 3.1]
sorcus has joined #crystal-lang
DTZUZU has quit [Ping timeout: 260 seconds]
DTZUZU has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #crystal-lang
lanodan has quit [Read error: Connection reset by peer]
lanodan has joined #crystal-lang
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
<FromGitter> <Dan-Do> > https://play.crystal-lang.org/#/r/b6vj ⏎ ⏎ @naqvis Can you help me out with this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60a91740688a2624b8a6537b]
<FromGitter> <Dan-Do> I dont want to declare `setter my_proc : Proc(String, JSON::Any, Hash(String, String))`
<FromGitter> <Dan-Do> the error is ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60a91780bdecf719a0726174]
<FromGitter> <Dan-Do> Your code is ⏎ ⏎ ```@my_data = @my_proc.call(layout, JSON.parse(data))``` [https://gitter.im/crystal-lang/crystal?at=60a91813fec22b4786d4c704]
<FromGitter> <Dan-Do> Isn't the same?
<FromGitter> <Blacksmoke16> the key is line 31 in that playground link. I.e. converting the hash to a `String` before passing it to render
<FromGitter> <Dan-Do> oops, my bad :D
<FromGitter> <Dan-Do> changed it to `@my_data = transform.call(layout, data.to_json)`
<FromGitter> <Dan-Do> now error is `Error: no overload matches 'Proc(String, JSON::Any, Hash(String, String))#call' with types String, String`
<FromGitter> <Blacksmoke16> now you dont have the `JSON.parse`
<FromGitter> <Dan-Do> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60a91a863d43a15a65bd1c24]
<FromGitter> <Dan-Do> isn't it?
<FromGitter> <Dan-Do> uhm, no `Error: no overload matches 'JSON.parse' with type JSON::Any`
<FromGitter> <Blacksmoke16> you didnt have it in line 12 of that link
<FromGitter> <Blacksmoke16> i.e. when you go to call the proc
<FromGitter> <Dan-Do> got it, now changed to ⏎ ⏎ ```@my_data = transform.call(layout, JSON.parse(data.to_json))``` [https://gitter.im/crystal-lang/crystal?at=60a91eae0ff6de262b21e128]
<FromGitter> <Dan-Do> weird, huh :D
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
DTZUZU has joined #crystal-lang
DTZUZU_ has quit [Ping timeout: 240 seconds]
<FromGitter> <naqvis> @Dan-Do please give some love to type annotations, they are going to help you in long run and identify problems at the right spot. ⏎ `def render(layout, data)` Your current method signature doesn't reveal, what is this method expecting to work properly ⏎ ⏎ imagine what would happen when someone call it `foo.render(1, "fooo")` ? [https://gitter.im/crystal-lang/crystal?at=60a925fd0ff6de262b21f364]
<FromGitter> <naqvis> compiler will yell at you stating that block parameter can't be executed, but that isn't the fault of the block
<FromGitter> <naqvis> type annotating signature to`def render(layout : String, data : Hash)` will complain at the right location, where problem is happening
<FromGitter> <naqvis> another point i would like to make is `if var` construct is used if you are working with optional types (types who might be nil)
<FromGitter> <naqvis> block parameter is never going to be nil (as per the signature), so you needn't to use such construct there
<FromGitter> <naqvis> just few random thoughts 😄
<FromGitter> <Dan-Do> yeah, I appreciate that ❤️
<FromGitter> <naqvis> 👍
lanodan has left #crystal-lang ["WeeChat 3.1"]
<FromGitter> <lebogan> Please, let me know if this is the right place for my issue. I was using kemal-flash which relied on json.mapping which broke in 0.36.0. Not sure how to fix. Anyone know of a replacement shard for neovintage/kemal-flash? Or maybe steer me to how to fix? Thanks.
<jhass> JSON.mapping was extracted to https://github.com/crystal-lang/json_mapping.cr
<FromGitter> <Blacksmoke16> Or ofc update it to use json serializable
<FromGitter> <lebogan> @Blacksmoke16 , @jhass thank both of you for the quick response. After some struggling, I managed to update to json serialize. I'm notifying the shard maintainer.
postmodern has joined #crystal-lang
<postmodern> is there a short-hand like enum_for, for calling a method that yields args, and appending them to an Array?
<FromGitter> <Blacksmoke16> Hm?
<postmodern> if you have method A which yields data, and you want to write an overloaded version of method A that returns an Array of that data, is there a macro for that?
<postmodern> i'm assuming i have to write that code which initializes an Array, calls the method with a block, and appends the yielded args to the array, then return the array
<FromGitter> <Blacksmoke16> yea theres not a macro to do that for you