ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <bew> ECR is a templating system that works at compile time, here `page` is only known at runtime (when you run your program) not at compile time @everdev
<FromGitter> <bew> If you need a runtime templating system you need another tool, like crinja
sagax has quit [Remote host closed the connection]
<travis-ci> crystal-lang/crystal#514c461 (master - Add missing tests for CSV.build with custom separator/quote_char (#6008)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/371318078
<DeBot> https://github.com/crystal-lang/crystal/pull/6008 (Add missing tests for CSV.build with custom separator/quote_char)
^raz^ has quit [Changing host]
^raz^ has joined #crystal-lang
^raz^ is now known as raz
greengriminal has quit [Quit: Leaving]
Raimondi has joined #crystal-lang
jokke has quit [Quit: WeeChat 2.1]
<FromGitter> <asantebuil> I cant to .map to a Hash
<FromGitter> <bew> No you can't, but iirc there is a transform_values that had been pr
<FromGitter> <asantebuil> hmm why did it allow me to do it in play.crystal online compiler?
<FromGitter> <bew> ?
<FromGitter> <bew> Can you share a link that works?
<FromGitter> <asantebuil> sure
<FromGitter> <asantebuil> https://play.crystal-lang.org/#/r/3y5a
<FromGitter> <bew> Oh yeah you can, but you get an array back, not a hash
<FromGitter> <bew> I was talking about this pr #4385
<DeBot> https://github.com/crystal-lang/crystal/pull/4385 (Add Hash#transform_keys and Hash#transform_values)
<FromGitter> <asantebuil> well i want an array back but locally on my machine its not allowing map. It's giving me " undefined method 'map' for String"
<FromGitter> <asantebuil> nevermind i see
<FromGitter> <bew> ^^ the relevant bits was `for String` :)
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <asantebuil> it seems to be a weird scop issue. im coding a bot, i have a leaderboard variable as a hash thats at a top level. i then have a client.on event listener and inside the listener is a case statement
Yxhuvud has joined #crystal-lang
<FromGitter> <asantebuil> i am calling leaderboard in one of the when statements. however if i were to unhoist leaderboard and put it into the local statement it worksa
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Client Quit]
<FromGitter> <sherjilozair> Assigning a variable to `Random.rand` works, but assigning it to `Random.rand(128.0)` gives a type inference error. Is this a bug? https://play.crystal-lang.org/#/r/3y5w
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
pabs has quit [Ping timeout: 256 seconds]
pabs has joined #crystal-lang
Raimondi has quit [Quit: WeeChat 1.9.1: ¡Chau!]
aarongodin_ has joined #crystal-lang
avdi_ has joined #crystal-lang
Majost_ has joined #crystal-lang
jetpack_joe_ has joined #crystal-lang
early` has joined #crystal-lang
Raimondi has joined #crystal-lang
g-glitch has joined #crystal-lang
Majost has quit [Ping timeout: 256 seconds]
early has quit [Ping timeout: 256 seconds]
avdi has quit [Ping timeout: 256 seconds]
aarongodin has quit [Ping timeout: 256 seconds]
briank has quit [Ping timeout: 256 seconds]
braidn[m] has quit [Ping timeout: 256 seconds]
jetpack_joe has quit [Ping timeout: 256 seconds]
swav has quit [Ping timeout: 256 seconds]
Majost_ is now known as Majost
aarongodin_ is now known as aarongodin
avdi_ is now known as avdi
jetpack_joe_ is now known as jetpack_joe
swav has joined #crystal-lang
betofloresbaca[m has quit [Ping timeout: 246 seconds]
byteflame has quit [Ping timeout: 246 seconds]
olbat[m] has quit [Ping timeout: 240 seconds]
Renich has quit [Ping timeout: 240 seconds]
thunker[m] has quit [Ping timeout: 255 seconds]
cptaffe has quit [Ping timeout: 260 seconds]
kixune[m] has quit [Ping timeout: 256 seconds]
fifr[m] has quit [Ping timeout: 255 seconds]
kp666[m] has quit [Ping timeout: 276 seconds]
<FromGitter> <bew> No, I think that's because the return type of that method is not specified.
<FromGitter> <bew> In general you should not rely on that, and should always manually specify the type like : `@a : Float32`
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <bew> @asantebuil if you're trying to access a local variable at toplevel, from inside a method, then it's expected, you can only access local vars from the method, not outside of it
Yxhuvud has joined #crystal-lang
<FromGitter> <girng> im not sure if anyone saw my example i posted last week of creating 370k classes, but memory stayed around the same. would that way be the right thing to for monster generation in maps? players will be able to create a map, and it'll select amount of monsters to spawn in the mob at certain positions. im thinking 100 or 200 per map dependent the map size. (all will be randomly generated) ⏎ ⏎ so.. my question
<FromGitter> ... is do i do an Array of NamedTuples for the monsters inside the GameServer class, or just do an Array of "Monster" Classes?
<FromGitter> <asantebuil> @bew yeh everything was solved when using class instance variables, i was really lazy and didnt want to convert a simple example to a class but i did anyway
<FromGitter> <asantebuil> its much better now
<FromGitter> <girng> Monsters will only need properties (or keys) of current_health, position, damage, a few others
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
<FromGitter> <girng> Each game instance server will be using those $4.99 cheap vpses, so i'm thinking around no more than 100 players will be on per instance. so the array of monsters in each game total will be around 20,000. that's assuming if all 100 players each have their own map and not playing with others
<FromGitter> <girng> `for the monsters inside the GameServer` class. I mean Game class, not GameServer
<FromGitter> <sherjilozair> @bew `Random.rand` actually has `Float64` specified as the return type. There's no ambiguity. And even if there is why can't it infer the type as `(Float32 | Float64)` or `Float`. If I have to specify all the types, then Crystal has little point.
<FromGitter> <sherjilozair> @girng Which framework are you using for this game?
<FromGitter> <girng> godot engine, with a crystal TCP server as the back-end
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <bararchy> @girng Monster class will allow you to add and enhance while keeping same type reference all over the code
Yxhuvud has joined #crystal-lang
<FromGitter> <girng> Okay sweet. Monster class it is then! Let's GO!
<FromGitter> <sherjilozair> @girng Didn't know it was possible to use Godot with Crystal. How are you doing this?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <girng> @sherjilozair very simple actually, crystal intertwines with Godot PERFECTLY ⏎ ⏎ ###How to send messages from Godot, to *Crystal*: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae14aa01130fe3d3619a2b9]
<FromGitter> <sherjilozair> Wait, so you're using crystal just for the server code, right? The client code is still in GDscript?
<FromGitter> <girng> yeah!
<FromGitter> <girng> it's all read/sent as individual messages too. no need to do your own custom "\n" package parsing stuff (that i was originally doing with nodejs lol). very nice
<FromGitter> <sherjilozair> I see. Pretty cool. Is this an MMO-type game where most of the computation is in the server?
<FromGitter> <girng> well, just player movement and inventory, stashing, updating / saving skills, using a skill, chatting, lobby join leave, passive tree update, equipping gear. coincides with `db` module very nice
<FromGitter> <girng> but most of that is for the master server, my game instance server will have other stuff too. but it's instance based
<FromGitter> <girng> 6 players per game, spawn then in fibers on $4.99 VPSs 😂 LOLL
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <schoening> In VSCode I seem unable to set the indentation to 4. Is this intentional? I know crystal and its devs are very opinionated but forcing indentation :/ ?
Yxhuvud has joined #crystal-lang
<FromGitter> <schoening> Could be a bug in vscode, but I figured Id ask coz I dont see any settings issues that I made.
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
<FromGitter> <bararchy> @girng that's really cool, you should blog post about how you integrate with Godot
<FromGitter> <bararchy> It could interest a lot of devs
<FromGitter> <girng> yah, maybe one day. thx for support.
johndescs_ has joined #crystal-lang
johndescs has quit [Ping timeout: 240 seconds]
johndescs_ is now known as johndescs
rohitpaulk has joined #crystal-lang
moei has quit [Ping timeout: 255 seconds]
moei has joined #crystal-lang
<FromGitter> <Qwerp-Derp> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae161f21130fe3d3619f933]
<FromGitter> <Qwerp-Derp> this is my umpteenth draft at making a markup for Hedron
<FromGitter> <Qwerp-Derp> should i make it crystal-y or should i stick to something more like qml
sagax has joined #crystal-lang
<FromGitter> <girng> how does a stack overflow happen with crystal? only through recursive methods? (infinite loops)?
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <girng> wow, so using JSON.mapping is pretty nice because i can then just use to_json on the class
<FromGitter> <girng> im using it for my `game` class type, very nice
<FromGitter> <bararchy> @girng I use it all the time:)
<FromGitter> <bararchy> If you need to transfer the data or want a smaller footprint checkout message pack
Nathanaelle has joined #crystal-lang
<FromGitter> <girng> you know what would be really cool, is if we have an initialize method setup inside a class! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae16995b01085166cc105aa]
<FromGitter> <girng> @bararchy hahah yeah i know right, that would be very cool tow ork in godot
<FromGitter> <sherjilozair> How can I run a map on each line of a file?
<FromGitter> <sherjilozair> The API only provides iterators. :|
<FromGitter> <bararchy> ```File.open("/path/to/file").each_line do |line| ⏎ line.split.map # Like this? ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ae16d386d7e07082b35cb71]
<FromGitter> <gdotdesign> `File.read('path/to/file').lines.each { |line| puts line }` Iterator has each https://crystal-lang.org/api/0.24.2/Iterator.html#each-instance-method
<FromGitter> <gdotdesign> or you can just convert it to an Array with `to_a`
<FromGitter> <bararchy> I think that `.each_line` is better because it wont create an intermidate array, not sure though
<FromGitter> <sherjilozair> @bararchy Would your code produce an array though?
<FromGitter> <bararchy> `.lines`
<FromGitter> <bararchy> will produce an array of all lines
<FromGitter> <sherjilozair> I tried this but it actually returns nil: ` @map = File.read(@mappath).lines.each { |line| (0...128).map { |index| line[2*index...2*index+2].to_i(16) }}`
<FromGitter> <sherjilozair> Ah just need to use map instead of each.
<FromGitter> <sherjilozair> @bararchy I think there is no way to do what I'm doing without producing the intermediate array.
<FromGitter> <gdotdesign> an iterator has `map` as well https://crystal-lang.org/api/0.24.2/Iterator.html#map%28%26func%3AT-%3EU%29forallU-instance-method
moei has quit [Quit: Leaving...]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @sherjilozair intemediate array is not an issue if it's something you actually use :) ⏎ also, it makes sense for some usecases where you can't avoid it
<FromGitter> <bararchy> or in other words, don't kill your-self over it XD
<FromGitter> <sherjilozair> I see. Thanks @gdotdesign @bararchy
DTZUZO has quit [Ping timeout: 255 seconds]
moei has joined #crystal-lang
jokke has joined #crystal-lang
<FromGitter> <girng> lol if u add a o after g it would be godotdesign
<FromGitter> <girng> small world we live in, my friends.
<FromGitter> <bararchy> yeha I was sure it was godot design my self
<FromGitter> <girng> lol :)
ua has joined #crystal-lang
<FromGitter> <girng> hmm, seems like json for large amount of data isn't really efficient because it sends redundant keys
<FromGitter> <girng> i mean, it works nice for CMD name, and getting certain info. im just saying, i wonder if there is a solution to the redundant key problem. i know you mentioned msgpack, but unfortunately there is no module for that in godot for the client :(
<FromGitter> <bararchy> you can do full binary protocol
<FromGitter> <girng> for example, look here: https://paste.ee/p/8Vpt5
<FromGitter> <girng> let's say a player is request to view all the open games
<FromGitter> <girng> look at all those redundant keys lol
<FromGitter> <girng> that means the to_json method has to work harder right?
<FromGitter> <girng> plz note: im not trying to put down json at all. i will in fact continue to use it, i LOVE IT for simple commands n whatnot. but for large information, i feel like it isn't right
<FromGitter> <oprypin> we have discussed this already, nothing more to add
<FromGitter> <girng> premature optimization thing?
<FromGitter> <girng> is this one?
<FromGitter> <oprypin> i mean mainly the other suggested options
<FromGitter> <oprypin> understandably, they are not easily applicable
<FromGitter> <oprypin> that's why you use a real programming language, not some hacky "engine"
<FromGitter> <bararchy> @oprypin godot is hacky ?
<FromGitter> <girng> well, to be fair he prob thinks it is after hearing me talk about it all the time LOL
<FromGitter> <girng> WAIT
<FromGitter> <girng> `key: the property name in the JSON document (as opposed to the property name in the Crystal code)` i use new key, for example `game_description` can just be `d`. with over 500 results, that's an insane difference.
<FromGitter> <girng> @bararchy Now look at it: https://paste.ee/p/vjGcx
<FromGitter> <girng> Wow, cut that size a lot =]. this is why i need to read the docs more :D
<FromGitter> <bararchy> can't you just Zip it before sneding ?
<FromGitter> <girng> no idea, but json.mapping is prettty damn powerful, just gonna stick with this for now
olbat[m] has joined #crystal-lang
<FromGitter> <drum445> If I wanted to use JSON Mapping for my classes but only supply some of the fields during init time, how would I best go about that?
<FromGitter> <bararchy> you can add optional fields
<FromGitter> <bararchy> ```test : String?```
<FromGitter> <bararchy> etc..
<FromGitter> <bararchy> so they can be initalized as nil
<FromGitter> <bararchy> and you can add value later
<FromGitter> <bararchy> or you could just save it as a big hash
<FromGitter> <bararchy> and merge in new keys
<FromGitter> <bararchy> and in the end do `.to_json`
Raimondii has joined #crystal-lang
<FromGitter> <girng> So `location: {type: String, nilable: true},` is the same as `location : String?`
Raimondi has quit [Ping timeout: 264 seconds]
<FromGitter> <bararchy> yeha
Raimondii is now known as Raimondi
<FromGitter> <girng> lmao awesome
<FromGitter> <drum445> oh nice, so i'd just pass a nil through to the initialize method?
<FromGitter> <bararchy> yeha
<FromGitter> <drum445> Marvelous, cheers @bararchy
<FromGitter> <drum445> Reckon it's always worth using JSON.mapping over the classic getter/setter way?
<FromGitter> <bararchy> or don't even pass, do something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae196747c3a01610d219efd]
<FromGitter> <bararchy> and have a ⏎ ⏎ ```def to_json ⏎ @my_json.to_json ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ae1969815c9b03114398df2]
<FromGitter> <bararchy> etc..
<FromGitter> <bararchy> if it makes sense
rohitpaulk has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #6013: Formatter: fix call args indent in case of backslash follows method name (master...fix/crystal-format/method-name-backslash-indent) https://git.io/vpCNQ
<FromGitter> <drum445> I don't quite get that mate
<FromGitter> <drum445> Mind putting it in a playground?
olbat[m] has quit [Ping timeout: 255 seconds]
<FromGitter> <drum445> struggling with that :(
flaviodesousa has joined #crystal-lang
<FromGitter> <bararchy> @drum445 https://play.crystal-lang.org/#/r/3yav
<FromGitter> <bararchy> :)
<FromGitter> <bararchy> one with output: https://play.crystal-lang.org/#/r/3yax
<FromGitter> <drum445> Good stuff, thanks matey
<FromGitter> <bararchy> np
<FromGitter> <drum445> so you'd use that over json.mapping?
<FromGitter> <bararchy> if you want to add keys after creating of object then yes, but it all really depends on the usecase
<FromGitter> <bararchy> mapping is great for... mapping :) ⏎ from JSON to Object with good parsing helpers
<FromGitter> <bararchy> it seems you want Object to JSON
<FromGitter> <bararchy> I would do that, or, just use an Hash stright on without a class
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae1a34d15c9b0311439d275]
<FromGitter> <bararchy> etc..
<FromGitter> <drum445> Makes sense, thanks again
<FromGitter> <bararchy> np
<FromGitter> <drum445> something like that for the optional ones?
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
olbat[m] has joined #crystal-lang
tilpner has quit [Quit: :wq]
tilpner has joined #crystal-lang
braidn[m] has joined #crystal-lang
fifr[m] has joined #crystal-lang
byteflame has joined #crystal-lang
cptaffe has joined #crystal-lang
Renich has joined #crystal-lang
betofloresbaca[m has joined #crystal-lang
thunker[m] has joined #crystal-lang
kp666[m] has joined #crystal-lang
kixune[m] has joined #crystal-lang
jokke has quit [Quit: WeeChat 2.1]
<FromGitter> <girng> is there a difference in performance of defining a Struct and then using it compared to doing like an inline NamedTuple? what's difference, since both are generated on the stack right?
DTZUZO has joined #crystal-lang
<oprypin> no difference
<FromGitter> <girng> personally, i like inline NamedTuples for some reason so ima just do what is more comfortable for me then
<FromGitter> <girng> thank you
<crystal-gh> [crystal] RX14 closed pull request #6004: Remove dependency on libxml from spec runner (master...jm/feature/spec-remove-libxml-dep) https://git.io/vpnPx
<FromGitter> <girng> eh, i take that back i like structs better
<RX14> you shouldn't like either of them better
<RX14> they're different things for different cases
<RX14> and you should use both
<FromGitter> <straight-shoota> I believe it's a hopeless case, RX14 😆
<FromGitter> <girng> rude
Nathanaelle has quit [Ping timeout: 255 seconds]
<FromGitter> <bararchy> @girng he was joking, no need to take it personaly :)
<FromGitter> <bararchy> anyway, what RX14 is saying is currect, each of them have it's own use, they both can be containers for data, but one is for X and the other for Y
<FromGitter> <girng> which one falls under TEMPORARY DATA?
Nathanaelle has joined #crystal-lang
<RX14> named tuples are more internal and ad-hoc
<RX14> i'd not expose it in the API of a class
<RX14> most of the time
<RX14> record (struct) is a lot better for API work
<RX14> tempoary data isn't very descriptive
<FromGitter> <girng> for example: Client class: https://paste.ee/p/C8WZP, and Game class: https://paste.ee/p/u4MGD ⏎ ⏎ when a client (the player), creates a game. i have a `property games = {} of String => Game` in my masterserver class. so now, this hash is referencing the game name to the game class. that game class is now holding a hash of all players in that game. ⏎ ⏎ so, when a user requests game information for a
<FromGitter> ... specific game, i send the game name. then, check if that game name exists in `games[incoming_game_name]?` if that is true, that means it exists. ... [https://gitter.im/crystal-lang/crystal?at=5ae1c6b66d7e07082b379704]
<FromGitter> <girng> "and the player's in an array", i mean just an array of all the player's id's or names. not their entire property values from a `JSON.mapping`
<travis-ci> crystal-lang/crystal#fdda990 (master - Remove dependency on libxml from spec runner (#6004)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/371526873
<DeBot> https://github.com/crystal-lang/crystal/pull/6004 (Remove dependency on libxml from spec runner)
<FromGitter> <girng> i guess. maybe i should ask. is it possible to have different json.mappings? I could enable one just for when requesting game info, and use another when requesting more. that would make it easiest i think.
<FromGitter> <drum445> Is it possible to only send certain fields in a JSON.mapping object when using to_json ?
<FromGitter> <drum445> @bararchy would appreciate your help on this again
<FromGitter> <j8r> @bararchy PR pending for you ❤️ https://github.com/crystal-community/hardware/pull/7
<FromGitter> <j8r> Note that I'm working on getting CPU/memory for PID
<FromGitter> <straight-shoota> @girng @drum445 You can't have different mappings in the same model and you can't customize the methods generated by that macro
<FromGitter> <drum445> For example: https://play.crystal-lang.org/#/r/3yby ⏎ I don't want the ID to be brought back using to_json
<FromGitter> <straight-shoota> The solution is either using a converter, different models or a custom implementation of `to_json`
tilpner has quit [Ping timeout: 264 seconds]
<FromGitter> <drum445> It brings back null values now though :( any idea how to better implement a to_json sir?
<FromGitter> <girng> well, ima see if i can use a macro inside the json.mapping block then
<FromGitter> <girng> if conditions, to use certain values, etc
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vpWGY
<crystal-gh> crystal/master 3afc781 Johannes Müller: Improve #inspect format for Time types (#5794)...
z64 has quit [Quit: WeeChat 2.0.1]
z64 has joined #crystal-lang
<FromGitter> <straight-shoota> @drum445 https://play.crystal-lang.org/#/r/3yc0
<FromGitter> <straight-shoota> @girng that sounds like it would make things unnecessarily complicated
<FromGitter> <drum445> that;s great, thanks @straight-shoota
duane has joined #crystal-lang
<travis-ci> crystal-lang/crystal#3afc781 (master - Improve #inspect format for Time types (#5794)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/371553530
<DeBot> https://github.com/crystal-lang/crystal/pull/5794 (Improve #inspect format for Time types)
<FromGitter> <drum445> anyways to remove a key from a json object?
<FromGitter> <yxhuvud> Hmm, https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ was a great article. I think I'm convinced by the argument it makes about fundamental threading primitives.
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
<FromGitter> <girng> why does this work: ⏎ ⏎ ``` client.send {game_name: "hey", game_description: "test"}, "GAMEINFO"``` ⏎ ⏎ gives `Syntax error in src/LoginHandler.cr:285: expecting token 'CONST', not 'DELIMITER_START' ... [https://gitter.im/crystal-lang/crystal?at=5ae1da9215c9b031143afba9]
hightower2 has quit [Ping timeout: 240 seconds]
duane has quit [Ping timeout: 248 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <drum445> anyway to improve that?
<FromGitter> <straight-shoota> @girng `{` after a method name is interpreted as block delimiter
<FromGitter> <straight-shoota> not tuple literal
<FromGitter> <straight-shoota> you'll need to wrap the argument in parenthesis
<FromGitter> <girng> ok
<FromGitter> <straight-shoota> @drum445 That looks utterly complicated
<FromGitter> <straight-shoota> And unnecessarily makes a round trip of JSON serialization
<FromGitter> <straight-shoota> what's wrong with the code I showed you?
<FromGitter> <straight-shoota> @yxhuvud true, the argument is really compelling
<FromGitter> <straight-shoota> the thing is, `go` and `spawn` are nice and simple, yet the implications can be complicated. And it's usually not really that often that you need to run a concurrent task
<FromGitter> <drum445> The code you sent was nice, but it would mean having to add a line of code for each json key
<FromGitter> <drum445> so if i had an object with 20 JSON keys it would be 20 lines long
<FromGitter> <straight-shoota> then put it in a macro
<FromGitter> <straight-shoota> which receives the named tuple literal from `JSON.mapping` and expands to calling `JSON.mapping` with that argument and generate `to_json` directly
<FromGitter> <straight-shoota> where the `id` is stripped off
<FromGitter> <drum445> Mate, I'm sorry but could you playground that. It's a bit over my head
<RX14> @drum445 the most reasonable way to do this is like this: https://play.crystal-lang.org/#/r/3ycd
<FromGitter> <drum445> Thansk @RX14 but is there a way to change that to not show nils?
<RX14> @drum445 if you're 100% required to not have nil values, you can nick this snippet: https://github.com/meew0/discordcr/blob/8f0f47a42e719146ac980c5c8a999ef51aaab38a/src/discordcr/rest.cr#L100-L109
<FromGitter> <drum445> yeah that is very similar to the way I did it, is there a way to loop through self;s paramaters?
<RX14> no, you probably don't want that either
<RX14> being 100% explicit about how you want to represent the json is far more flexible
<RX14> if you suddenly want to do for example this: https://play.crystal-lang.org/#/r/3ycf
<RX14> the only reasonable way to do that is to tweak it
<RX14> using macros and attempting to deduplicate this is dry too far
<RX14> so it's better to be 100% explicit about both the internal and external JSON mapping
<RX14> because making it iterate through the json mapping and filter out fiends looses you a lot of flexability and explicitness
<RX14> fields*
<FromGitter> <drum445> ah ok, I agree with you now seeing that example, cheers boss
<RX14> you learn after a while that copy and paste is your friend too
<FromGitter> <drum445> sorry?
<RX14> i'm just rambling on a bit more about dry )or the lack of it)
<FromGitter> <drum445> surely copy and paste is the enemy then ;)
<RX14> not always
<RX14> that's why I added "or the lack of it"
<RX14> this is a specif case where DRY doesn't help
<RX14> was the point I was trying to make
<FromGitter> <drum445> indeed man
<RX14> copy and pasting the json.mapping tuple into encode_tuple is better here
<FromGitter> <drum445> so your second example?
<RX14> yes
<FromGitter> <drum445> ok nice, where would you recommend I put that encode_tuple function?
<FromGitter> <drum445> if multiple classes need it?
<RX14> if you can put all your classes into one file, then make it a private def at the top of the file
<RX14> if your classes contain logic as well as data representation, then that's not a good idea
<RX14> and you should just put it on your namespace module
<RX14> MyApp.encode_tuple
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
<FromGitter> <girng> Okay.. i think i got it! https://paste.ee/p/UDOSl
<FromGitter> <girng> i don't like using {} of Int32 => String and Hash(Int32, String). is there 1 way to do it, globally?
<RX14> the universal syntax is Hash(Int32, String)
<RX14> because you can do Hash(String, Int32).new, or use Hash(Int32, String) as the type
<RX14> I tried to get {} of Int32 => String removed but people complained for some reason
<FromGitter> <girng> okay thx, i'll use that.i just like consistency / less confusing when i read over it ]
<FromGitter> <girng> much nicer: https://paste.ee/p/F4UVU
jokke has joined #crystal-lang
<FromGitter> <girng> i think it was bew, or j8r but one of them wanted me to use structs so there u go, i like it too :D
<RX14> why do you have = ""
<RX14> why not just create a constructor which initializes the name and description
<FromGitter> <girng> cast as string?
<RX14> no, I mean avoid ever creating a GameInfo with empty information
<FromGitter> <girng> well, when player request GameInfo i just do ⏎ game_info = GameInfo.new and then below: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae1e8895d7286b43a6e9507]
<RX14> @girng this is how i'd write it: https://carc.in/#/r/3yck
<RX14> there doesn't need to be a default value
<RX14> you can make description and name immutable
<RX14> and just initialize it directory in the constructor
tilpner has joined #crystal-lang
<FromGitter> <girng> interesting
<RX14> @girng with your code you can do gameInfo.new and then never initialize the information
<RX14> it's easy to make mistakes
<FromGitter> <girng> but i mean what do you mean default value, there will always be a value there when it's called? or is it because of the property macro,sorry bit confused
<RX14> in my code that's impossible
<FromGitter> <girng> bcz i fill in the info
<FromGitter> <girng> but i mean your code looks way cleaner...
<RX14> but it's much better to fill in the information by passing it to .new
<FromGitter> <girng> Ohh as parameter
<RX14> instead of setting it manually after
<RX14> it's possible to forget to initialize it
<FromGitter> <girng> oh i see
<RX14> the default values i'm talking about are `""`
<RX14> my code gets rid of them
<RX14> it forces you to initialize the GameInfo
faustinoaq has quit [Quit: IRC client terminated!]
<RX14> with the required info
<FromGitter> <girng> yeah, and if i forgot about them, unecessary stuff being generated
<FromGitter> <girng> =BAD, correct?
<RX14> if you ever edit GameInfo to add a new variable, then you'd edit the constrictor
<RX14> and if you forgot to initialize it somewhere, you'd fail to compile
<RX14> instead of compile fine and return bad data
<FromGitter> <girng> then the player get's DC'd and reports bug on forum = waste time :D
<RX14> sure
<FromGitter> <girng> lol gotcha.
<FromGitter> <girng> i get it
<FromGitter> <girng> well, kinda want to clean up my Client class now, but might have a bit too much parameters lol
<RX14> crystal gives you the tools to write code which is hard to misuse, but it doesn't force you to write code that is hard to misuse
<RX14> getting into the habit of thinking about how to break your own code and how to prevent that is a good skill
<RX14> @girng you can always use named paramters
<RX14> .new(
<RX14> foo: bar,
<RX14> baz: bing
<RX14> )
early` has quit [Quit: Leaving]
<RX14> etc.
<RX14> but with the right indents
<FromGitter> <girng> oh lord
<FromGitter> <girng> that would be nice
<RX14> it's the same code length :P
<RX14> well, you add 1 more line for ) but that's unimportant
<FromGitter> <girng> bcz in my client.new now it's kinda mess. kinda the same thing in GameInfo i showed u lol
<RX14> yeah
<FromGitter> <girng> and it gets worse when they hit handle_authentication, when i assign the values from db :D
<FromGitter> <girng> but sheis running fine, but im not in production thx gosh :D
<RX14> well, you'll write bad code, and it'll go wrong, and that's fine
<RX14> you'll look back at your code in a few years and think "that's terrible"
<RX14> but that's fine, because it means you've learned
<RX14> I do the same all the time
<FromGitter> <girng> ```code paste, see link``` ⏎ ⏎ saved two lines, code is safer with constructor too. nice! [https://gitter.im/crystal-lang/crystal?at=5ae1eb5715c9b031143b5e5a]
<crystal-gh> [crystal] RX14 closed pull request #6013: Formatter: fix call args indent in case of backslash follows method name (master...fix/crystal-format/method-name-backslash-indent) https://git.io/vpCNQ
<FromGitter> <girng> full: https://paste.ee/p/txl30
<RX14> you can probaby change name and players into getters now
<FromGitter> <girng> we can go deeper?
<FromGitter> <girng> i'm rdy :D
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
early has joined #crystal-lang
That_Guy_Anon has joined #crystal-lang
<FromGitter> <girng> so what's the major difference between
<FromGitter> <girng> defining the hash here: ⏎ `property players = Hash(Int32, String).new` ⏎ and then: ⏎ `players: Hash(Int32, String)` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5ae1edd57c3a01610d237f5a]
<FromGitter> <girng> i assume json mapping does that internally? when it runs the macro
rohitpaulk has quit [Ping timeout: 264 seconds]
That_Guy_Anon has quit [Quit: Leaving]
That_Guy_Anon has joined #crystal-lang
<FromGitter> <drum445> json mapping adds getters and setters yes
<FromGitter> <girng> @straight-shoota ok so i wrapped the namedtuples around with parenthesis
<FromGitter> <girng> https://play.crystal-lang.org/#/r/3yd0/edit still can't seem to get it work can u take a look plz
<FromGitter> <girng> https://crystal-lang.org/docs/syntax_and_semantics/literals/named_tuple.html im reading this ⏎ `{name: "Crystal", year: 2011} # NamedTuple(name: String, year: Int32)` so it should work
<FromGitter> <girng> just an inline NamedTuple, but means same thing
<FromGitter> <straight-shoota> I don't you can't combine type definitions with generic attributes and literal-type shortcuts
<travis-ci> crystal-lang/crystal#2e96cfc (master - Formatter: fix call args indent in case of backslash follows method name (#6013)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/371608801
<DeBot> https://github.com/crystal-lang/crystal/pull/6013 (Formatter: fix call args indent in case of backslash follows method name)
<FromGitter> <girng> but the docs say it's the same thing
<FromGitter> <girng> so one would assume it would wokr
<FromGitter> <straight-shoota> you need to write it as `Hash(Int32, NamedTuple(character_name: String))`
<FromGitter> <girng> why, when docs show `{name: "Crystal", year: 2011} # NamedTuple(name: String, year: Int32)`
<FromGitter> <girng> is that just there to confuse??
<FromGitter> <straight-shoota> that's different
<FromGitter> <straight-shoota> `{name: "Crystal", year: 2011}` is a named tuple literal
<FromGitter> <girng> i was thinking its synonymous syntax so i just used the inline version :P
<FromGitter> <straight-shoota> `NamedTuple(name: String, year: Int32)` is it's type
<FromGitter> <straight-shoota> and `{name: String, year: Int32}` is an equivalent notation of the type
<FromGitter> <straight-shoota> but true, the reference says it should be replaceable in generic type arguments
<FromGitter> <straight-shoota> `foo : Array({x: Int32, y: String})` works, `bar : Hash(String, {x: Int32, y: String})` doesn't
<FromGitter> <straight-shoota> that's a bug
<FromGitter> <girng> the thing is, i want to use either NamedTuples all over
<FromGitter> <girng> or I want to use {x: Int32} inline..
<FromGitter> <girng> i just want consistency
<FromGitter> <girng> bcz it confuses me
<FromGitter> <drum445> https://github.com/drum445/payment
<FromGitter> <drum445> correct way of creating a lib guys?
faustinoaq has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
<FromGitter> <xmonader> after `pacman -S crystal` ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae1f7fd270d7d37080c0f14]
<FromGitter> <bew> Did you update your system?
<FromGitter> <bew> `pacman -Syu`
<FromGitter> <xmonader> does it require global system update?
<FromGitter> <xmonader> @bew I can't do an update these days, bad internet in Egypt
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter> <xmonader> i can alias libLLVM 5.0 to libLLVM6.0
<FromGitter> <bew> Huh those are different versions, you can't just symlink
<FromGitter> <xmonader> ah, I got around such before with aliasing to the new version but not for llvm :D
Nathanaelle has quit [Ping timeout: 240 seconds]
<FromGitter> <girng> ```code paste, see link``` ⏎ ⏎ so now we don't need the `(` parenthesis around the namedtuple? but i needed them before? WTF [https://gitter.im/crystal-lang/crystal?at=5ae1f924109bb04332044224]
<FromGitter> <bew> And yes, you need to update your system, this is how arch works, this is a rolling release distro, the packages are built against the latest packages of everything, and are meant to be run the same way
<FromGitter> <xmonader> @bew ``` ⏎ Total Download Size: 2117.12 MiB ⏎ Total Installed Size: 8892.77 MiB ⏎ Net Upgrade Size: -258.69 MiB ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5ae1f9b07c3a01610d23bd92]
Nathanaelle has joined #crystal-lang
<FromGitter> <DRVTiny> How to do conditional compilation in macroses? ⏎ What is the syntax of {% if ? ⏎ How can i do {% if flag == 1 do %} macro_code {% end %}
<FromGitter> <DRVTiny> Macroses - its all about conditional compilation :)
<FromGitter> <DRVTiny> It is strange, but this VERY basic question was not discussed in docs at all!
<FromGitter> <bew> Hum.. You can try to upgrade llvm only, but I can't assure you that it won't break your arch (but it's very unlikely ut woukd though) @xmonader
<FromGitter> <bew> (I like your username :) )
<FromGitter> <xmonader> @bew Already trying to do llvm update or maybe i fallback to a crystal docker
<FromGitter> <xmonader> monads are cool :)
<FromGitter> <DRVTiny> ```code paste, see link``` ⏎ ⏎ Ok, sources is a best documentation [https://gitter.im/crystal-lang/crystal?at=5ae1fdc22d0e228d7bb618aa]
<FromGitter> <bew> Yeah @DRVTiny <3
hgost has joined #crystal-lang
<FromGitter> <DRVTiny> How to check whether macro-parameter was passed or no? ^)
<FromGitter> <DRVTiny> {% if param? %} ⏎ or ⏎ {% if param.is_a?(Nil) %} ⏎ or... ⏎ dont know :) [https://gitter.im/crystal-lang/crystal?at=5ae1fef36d7e07082b38d948]
<FromGitter> <bew> unless param
<FromGitter> <bew> And you can give it the default value nil
<FromGitter> <DRVTiny> I need to write macro ⏎ do_something(data, fl_do_some_additional_think)
faustinoaq has joined #crystal-lang
<FromGitter> <DRVTiny> macro do_smth(data, fl_and_this_too) ⏎ {% unless fl_and_this_too } ⏎ {% else %} ⏎ macro_code ⏎ {% end %} [https://gitter.im/crystal-lang/crystal?at=5ae1ffaab01085166cc42b77]
<FromGitter> <DRVTiny> ???
<FromGitter> <bew> Add `= nil` after `
<FromGitter> <bew> fl_and_this_too
<FromGitter> <bew> Or write 2 macros, one with 1 param, one with 2 param
Nathanaelle has quit [Read error: Connection reset by peer]
That_Guy_Anon has quit [Quit: Leaving]
Nathanaelle has joined #crystal-lang
<FromGitter> <DRVTiny> Wonderful example in string.cr ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae201971130fe3d361d5876]
<FromGitter> <bew> Here you go
Nathanaelle has quit [Read error: Connection reset by peer]
<FromGitter> <DRVTiny> Thank you, Benoit!
Nathanaelle has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<travis-ci> crystal-lang/crystal#caa250a (ci/fix-osx - Update distribution scripts): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/371656072
trillpoli[m] has joined #crystal-lang
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae20c332b9dfdbc3ad16616]
<FromGitter> <girng> json builder is AWESOME
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
<FromGitter> <DRVTiny> Oh, i am writing macro for to_json method generation !
<FromGitter> <DRVTiny> Exactly now
<FromGitter> <DRVTiny> And i dont know how to be with ⏎ ⏎ ```json.field "field_name", self.field_name``` ⏎ ⏎ 1) if field_name is optional field (can be nil) [https://gitter.im/crystal-lang/crystal?at=5ae20f397c3a01610d24323d]
<FromGitter> <r00ster91> @drum445 yes
Nathanaelle has quit [Ping timeout: 256 seconds]
<FromGitter> <bew> @DRVTiny checkout `JSON.mapping`, it's a macro!
<FromGitter> <DRVTiny> ```code paste, see link``` ⏎ ⏎ but ... there is no possibility to fo fldType[-1] ! :( :( :( [https://gitter.im/crystal-lang/crystal?at=5ae210cb1130fe3d361dac45]
<FromGitter> <bew> https://crystal-lang.org/api/0.24.2/Crystal/Macros/StringLiteral.html#ends_with%3F%28other%3AStringLiteral%7CCharLiteral%29%3ABoolLiteral-instance-method
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
<FromGitter> <DRVTiny> "Undefined macro method Path#ends_with?"
<FromGitter> <DRVTiny> Why fldType is "Path" in my case?
Nathanaelle has joined #crystal-lang
<FromGitter> <drum445> thanks @r00ster91
<FromGitter> <drum445> so this file: https://github.com/drum445/finance/blob/master/src/finance.cr ⏎ Is ok to just look like that @r00ster91 ?
<FromGitter> <DRVTiny> Hmm... It seems i have to use ⏎ ⏎ ```json_fields( { dependencies: Array(Int32)?, serviceid: Int32 } )``` ⏎ ⏎ But how to fldType =~ s/(^"|"$)//g ??? [https://gitter.im/crystal-lang/crystal?at=5ae21513109bb0433204d63e]
<FromGitter> <r00ster91> @drum445 yes thats ok. but if you will at the end really just have one file then i would place the code directly in this file
<FromGitter> <DRVTiny> gsub will help me, i know
<FromGitter> <drum445> cool cheers @r00ster91. I will be adding to it so will leave like that for now.
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <DRVTiny> @bew how to insert StringLiteral to generated code without double-quotes? ⏎ For example, ⏎ ⏎ ```puts ""hello""``` [https://gitter.im/crystal-lang/crystal?at=5ae2181d5d7286b43a6f9a95]
<FromGitter> <r00ster91> i think ⏎ `"#{word.id}"`
<FromGitter> <Givralix> hi! I have another question about C bindings
<FromGitter> <DRVTiny> @r00ster91 Thank you! That works! :)
<FromGitter> <Givralix> there's a point where I need to cast a struct pointer into another struct and that mostly works fine except for one value which stays the same as one of the values from the original struct
<FromGitter> <Givralix> I've tried making a function in C which does the cast and prints that value and in there it's fine but as soon as it's in Crystal, it changes
<FromGitter> <Givralix> does anyone have a clue ? :o
<oprypin> Givralix, i am intrigued, but would need more details (mainly code)
<FromGitter> <Givralix> as in enough code to run it or just the part where it goes wrong?
<oprypin> i dunno
<FromGitter> <Givralix> hold on
<FromGitter> <j8r> @bararchy I'm very honored for the mention, thank you! :-)
<FromGitter> <Givralix> @oprypin https://pastebin.com/3NLjqVtA I only included what seemed relevant to me
<FromGitter> <Givralix> (LibXCB::KeyPress is also 2, and the problem also happens with key release events, in which case it prints 3, LibXCB::KeyRelease's value)
<oprypin> Givralix, I see. these event thingies can be hard to understand in their C code. could you show the C code though?
<FromGitter> <Givralix> of the library?
<oprypin> yes
<FromGitter> <Givralix> ok
<oprypin> i think this will do best https://xcb.freedesktop.org/tutorial/events/
<FromGitter> <Givralix> yes
<FromGitter> <Givralix> I tried remaking the example at the end in Crystal
<oprypin> Givralix, ftp://www.x.org/pub/X11R7.7/doc/man/man3/xcb_key_press_event_t.3.xhtml
<oprypin> i mean, it clearly says that the first member is `uint8_t response_type` but you omitted it for some reason
<FromGitter> <Givralix> oh
<FromGitter> <Givralix> thank you a lot !
<FromGitter> <Givralix> sorry for your time
<crystal-gh> [crystal] bcardiff opened pull request #6015: Update distribution scripts (master...ci/fix-osx) https://git.io/vpWjo
kimvex has joined #crystal-lang
kimvex has quit [Client Quit]
<crystal-gh> [crystal] straight-shoota opened pull request #6017: Add IO::Stapled (master...jm/feature/io-stapled) https://git.io/vplvv
faustinoaq has quit [Quit: IRC client terminated!]
kurko_ has joined #crystal-lang
<travis-ci> crystal-lang/crystal#24b0e7e (ci/fix-osx - Update distribution scripts): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/371714712
faustinoaq has joined #crystal-lang
faustinoaq has quit [Client Quit]
Nathanaelle has quit [Ping timeout: 256 seconds]
alex`` has quit [Ping timeout: 248 seconds]
ua has quit [Ping timeout: 255 seconds]
ua has joined #crystal-lang
rohitpaulk has joined #crystal-lang
faustinoaq has joined #crystal-lang
faustinoaq has quit [Ping timeout: 240 seconds]
faustinoaq has joined #crystal-lang
sagax has quit [Ping timeout: 276 seconds]
sagax has joined #crystal-lang
thews has quit [Ping timeout: 256 seconds]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
_Leandro777_ has joined #crystal-lang
qard has joined #crystal-lang
<_Leandro777_> hi
<_Leandro777_> i have a question about the regular expressions
qard has quit [Remote host closed the connection]
<_Leandro777_> can i pre-compile them?
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
<_Leandro777_> hello, guys, is there a way to precompile the regular expressions??
<_Leandro777_> oh yes i guess this works: Regex.new()
<_Leandro777_> :D
<_Leandro777_> true?
<FromGitter> <bew> `a = /abc/` is exactly the same as `a = Regex.new("abc")`
<_Leandro777_> ok,
<_Leandro777_> is it precompiled?
<_Leandro777_> i am new
<FromGitter> <bew> Yes
<FromGitter> <bew> I just checked the code https://github.com/crystal-lang/crystal/blob/master/src/regex.cr
<_Leandro777_> ok cool, thanks :D
_Leandro777_ has quit [Quit: Page closed]
<FromGitter> <j8r> How can I have an infinite iterator? I would like to have a `def` that can take an argument to specify how number of times to iterate, or infinite times
<FromGitter> <j8r> the iterator must be inside because there are variables
<FromGitter> <bew> You can make your own iterator
<FromGitter> <bew> Checkout the api doc of `Iterator`
<FromGitter> <j8r> Thanks, already checked but can't find a way to make one (except having a BIIIGGG number) :/
<FromGitter> <j8r> *infinite iterator
<FromGitter> <j8r> I will find another way, `while true` would be fine
<FromGitter> <jwoertink> wouldn't using "loop" work?
<FromGitter> <j8r> yes, but if we want to have only x time?
<FromGitter> <jwoertink> with `break if x == 3`
<FromGitter> <jwoertink> or I guess
<FromGitter> <jwoertink> `break if needs_to_stop`
<FromGitter> <jwoertink> where `needs_to_stop` is like x == 3 || false
<FromGitter> <j8r> I use a `i += 1`
<FromGitter> <jwoertink> something like that
<FromGitter> <jwoertink> maybe a method where you either pass in the stop number or nil. If it's nil, then keep the loop going, if it's not, then += 1 until it hits that number
<FromGitter> <jwoertink> or just do `Float32::INIFINITY.times do` lol. I'm sure that wouldn't work, but would be funny
<FromGitter> <j8r> already tired haha :-P
<FromGitter> <bew> What's your usecase? How do you want to use it?
<FromGitter> <j8r> For the shard Hardware, in the module`Hardware::CPU`
<FromGitter> <j8r> I think I would of for a `loop; yield cpu; end`
<FromGitter> <j8r> when the method will called, there will have an infinite loop. The user can implement its break
<FromGitter> <j8r> I create the PR, you will see the use case :-)
sagax has quit [Ping timeout: 240 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
kurko__ has joined #crystal-lang
kurko_ has quit [Ping timeout: 265 seconds]
kurko_ has joined #crystal-lang
<crystal-gh> [crystal] RX14 closed pull request #6015: Update distribution scripts (master...ci/fix-osx) https://git.io/vpWjo
faustinoaq has quit [Quit: IRC client terminated!]
kurko__ has quit [Ping timeout: 248 seconds]
hgost has quit [Quit: leaving]
faustinoaq has joined #crystal-lang
<FromGitter> <j8r> here was my use case https://github.com/crystal-community/hardware/pull/8/files
thews has joined #crystal-lang
thews has joined #crystal-lang
thews has quit [Changing host]