ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.3 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<FromGitter> <andyfleming> Fair enough. I'll open up a separate PR for getter/setter examples to at least start a discussion there.
<RX14> i'm pretty sure there's an example around
<RX14> sorry
<RX14> issue
<FromGitter> <andyfleming> What is a property? and how is it different than an instance variable?
<RX14> @andyfleming you need newlines between your methods in your PR otherwise it looks ugly
<RX14> a property is a macro
<RX14> if you look at the docs you can see the expanded code
<RX14> it defines an instance variable
<RX14> and a getter/setter pair for the instance variable
<FromGitter> <andyfleming> Done. Also, I guess the other examples might need the methods added as well
<RX14> doing object.foo = "bar" in crystal is actually dispatching to the method foo= with the argument "bar"
<FromGitter> <andyfleming> Gotcha
<FromGitter> <andyfleming> So the options are effectively: getter/setter/property AKA both
<RX14> so the macro defines `def foo=` which recieves the argument and sets the instance variable
<RX14> like for example java getters/setters
<RX14> and yes
<RX14> property is just getter + setter
<RX14> essentially
<FromGitter> <andyfleming> :+1:
<FromGitter> <andyfleming> (that's a thumbs up in case it doesn't come through on IRC :D)
<RX14> it shows up as `:+1:`
<RX14> if that shows up as text in gitter
<RX14> so I got the message :)
<FromGitter> <andyfleming> Check out this example: https://play.crystal-lang.org/#/r/1i8s
<FromGitter> <andyfleming> Would the latter be better?
<RX14> yes
<RX14> in real code
<RX14> not for the docs
<FromGitter> <andyfleming> I say we break "Methods and instance variables” into “Instance Variables” and “Instance Methods”. Then we start with manual getters and setters, then introduce the shorthand and the `property` concept. It would be nice and clean. Then in the “Instance Methods” page, we can use the shorthand.
<FromGitter> <andyfleming> It could be BEAUTIFUL!
<RX14> hmm
<RX14> i think "new, initialize and annlocate" should be merged into "methods and instance variables" somewhat too
<RX14> that area of docs keeps coming up as a pain point
<FromGitter> <andyfleming> Yeah
<FromGitter> <andyfleming> `allocate` seems like an advanced topic that shouldn’t be mixed in with creation of class instances
<FromGitter> <andyfleming> (though a mention/link might be appropriate)
<FromGitter> <andyfleming> Opened an issue for discussion: https://github.com/crystal-lang/crystal-book/issues/62
<crystal-gh> [crystal] ysbaddaden closed pull request #3798: Fix: Socket.unix (master...fix-socket-unix) https://git.io/vMInp
<FromGitter> <taylorfinnell> Hello! I have a question about JSON#mapping, if anyone can help. Is it possible to use #mapping in such a way that this test could pass
<FromGitter> <taylorfinnell> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5865acc3058ca96737a71920]
<FromGitter> <taylorfinnell> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5865ad1b9d4cc4fc5356bdbd]
<FromGitter> <andyfleming> Did you intend to write `{ AbortDate: {type: "timestamp"} }` as a hash? or is it supposed to be a string? like `%({ "AbortDate" => {"type" => "timestamp"} })`?
<FromGitter> <taylorfinnell> i wrote it as a hash in order to call to_json on it so it would be cleaner than a json string
<FromGitter> <andyfleming> A hash would be `{ “AbortDate” => {“type” => "timestamp"} }`
<FromGitter> <taylorfinnell> sorry named tuple
<travis-ci> crystal-lang/crystal#4c5cc9c (master - Fix: Socket.unix (#3798)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187594422
<FromGitter> <andyfleming> ```%({ ⏎ AbortDate: { ⏎ type: "timestamp" ⏎ } ⏎ })``` [https://gitter.im/crystal-lang/crystal?at=5865ae51c895451b7535d45f]
<FromGitter> <andyfleming> It’s not too bad to write it as a string
<FromGitter> <taylorfinnell> that is nice, thank you!
<FromGitter> <andyfleming> ```obj = JSON.parse(%({ ⏎ "AbortDate": { ⏎ "type": "timestamp" ⏎ } ⏎ }))``` [https://gitter.im/crystal-lang/crystal?at=5865aed4af6b364a290e1e05]
<FromGitter> <andyfleming> Sorry, technically for JSON it still needs to be in quotes, but it’s not too bad
<FromGitter> <taylorfinnell> Sorry one sec, I don't think I am being clear
<FromGitter> <taylorfinnell> I am trying to figure out if `JSON#mapping` can used to get that test passing. So, I have a `Shape` class that I need to add JSON#mapping to. My confusion is how, if even possible I can have a method called `name` on Shape that returns the key of the json string. In this case `AbortDate`. It won't always be `AbortDate` so I can't just do `JSON.mapping(AbortDate: { ... })`. The full JSON file will look something like
<FromGitter> <taylorfinnell> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5865af559e6f00e74ad7e5f8]
<FromGitter> <taylorfinnell> Where AbortDate would be a Shape object, with a #name method returning AbortDate, and AbortIncompleteMultipartUpload would be a Shape with a name of AbortIncompleteMultipartUpload.
<FromGitter> <taylorfinnell> ```JSON.mapping(shapes: Hash(String, Shape))```
<FromGitter> <taylorfinnell> is close, but I lose access to the hash key name in the Shape class
<FromGitter> <andyfleming> Sorry, I’m not familiar enough with `JSON.mapping` to be of much help
<FromGitter> <bcardiff> AFK here but json mapping is for straight from input with some value conversions mainly (although there are some additional scenarios that are supported) if you want to create one object or another based on key name you might need to deal with Json PullParser
matp_ has joined #crystal-lang
matp has quit [Read error: Connection reset by peer]
<FromGitter> <bcardiff> Don't be afraid. Mapping is coded on top of pullparser and is really flexible
<FromGitter> <taylorfinnell> Thanks! Will look at pull parser :)
martinium has joined #crystal-lang
Yxhuvud has quit [Ping timeout: 260 seconds]
triangles2 has joined #crystal-lang
triangles has quit [Ping timeout: 265 seconds]
bcardiff has quit [Quit: bcardiff]
Kug3lis has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
Kug3lis has joined #crystal-lang
<crystal-gh> [crystal] andyfleming opened pull request #3802: Removing "In progress" label (master...patch-1) https://github.com/crystal-lang/crystal/pull/3802
<DeBot> https://github.com/crystal-lang/crystal/pull/3802 (Removing "In progress" label)
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
martinium has quit [Ping timeout: 246 seconds]
pcc54 has joined #crystal-lang
pcc54 has quit [Client Quit]
_whitelogger has joined #crystal-lang
triangles has joined #crystal-lang
triangles2 has quit [Ping timeout: 265 seconds]
pawnbox has quit [Ping timeout: 248 seconds]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
matp_ has quit [Read error: Connection reset by peer]
matp has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
matp has quit [Read error: Connection reset by peer]
matp_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
pawnbox has joined #crystal-lang
hako has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Kug3lis has joined #crystal-lang
<FromGitter> <radarek> Is there a way to check if method is defined? Any macro?
<FromGitter> <radarek> <BlaXpirit> thanks!
matp_ has quit [Quit: ZZzzzZz...]
vivus-ignis has joined #crystal-lang
vivus-ignis has quit [Client Quit]
soveran has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
matp has joined #crystal-lang
soveran has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 260 seconds]
Raimondii is now known as Raimondi
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 258 seconds]
pawnbox has joined #crystal-lang
Yxhuvud has joined #crystal-lang
damireh has joined #crystal-lang
soveran has quit [Ping timeout: 246 seconds]
etrepat has joined #crystal-lang
etrepat has left #crystal-lang [#crystal-lang]
Kug3lis has joined #crystal-lang
damireh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Kug3lis has quit [Client Quit]
damireh has joined #crystal-lang
<RX14> The new year's resolutions blog post was nice
<FromGitter> <andyfleming> Oooo, haven’t read it yet!
<FromGitter> <radarek> I read it and future for crystal looks very promising! :D
<txdv> i looked into my crystal
vivus-ignis has joined #crystal-lang
vivus-ignis has quit [Read error: Connection reset by peer]
<FromGitter> <andyfleming> lol
<FromGitter> <andyfleming> It was a good post. 1.0 here we come!
<RX14> Well I wouldn't get to attached to that 2017 release date
<RX14> New year's resolutions are often broken
<FromGitter> <andyfleming> Gotta have goals xD
<RX14> Not that we shouldn't try
<FromGitter> <andyfleming> I think it’s important for aspects like paralellism to take the time to get it right.
<RX14> I would rather release a 1.0 we can be proud of in 2018 than stick to a 2017 goal
<FromGitter> <andyfleming> Yeah, agreed
vivus-ignis has joined #crystal-lang
damireh has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <andyfleming> I’m going to bed, but check this out @RX14 https://github.com/crystal-lang/crystal-book/issues/62#issuecomment-269760186
<FromGitter> <firejox> Hi all, I have a question about generic class. why this code failed? ⏎ https://carc.in#/r/1ic3
hako_ has joined #crystal-lang
hako has quit [Ping timeout: 268 seconds]
Kug3lis has joined #crystal-lang
Philpax has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
triangles2 has joined #crystal-lang
Kug3lis has joined #crystal-lang
triangles has quit [Ping timeout: 258 seconds]
Kug3lis has quit [Client Quit]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
<RX14> @firejox looks like a big to me, at least the error message
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMLmB
<crystal-gh> crystal/master a8783e2 Andy Fleming: Removing "In progress" label
Kug3lis has joined #crystal-lang
<FromGitter> <firejox> @RX14 yeah, but when I write more complicate code in here https://github.com/firejox/crystal-async_await/blob/master/src/async_await/channel.cr#L283 ⏎ It would not trigger that error.
<RX14> Ok?
<RX14> That's why I said it was a bug
<RX14> Do you get an error with that code you linked?
<FromGitter> <firejox> @RX14 It got another strange error, but not the error in my first linked
<RX14> It would be helpful if you linked it...
<RX14> Though I might not be around to help you.
Yxhuvud has quit [Ping timeout: 252 seconds]
Philpax has quit [Ping timeout: 268 seconds]
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<travis-ci> crystal-lang/crystal#a8783e2 (master - Removing "In progress" label): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187681846
vivus-ignis has quit [Ping timeout: 258 seconds]
<FromGitter> <firejox> and if I remove protected, it would become this https://gist.github.com/firejox/6397fd93e4b78e1eaba3dd66d65b4fc1
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Kug3lis_off has quit [Quit: Textual IRC Client: www.textualapp.com]
Kug3lis has joined #crystal-lang
<jokke> hey
<jokke> is there a bignum lib for crystal?
Kug3lis has quit [Client Quit]
<FromGitter> <firejox> @jokke yes, you can try BigInt https://crystal-lang.org/api/0.20.3/BigInt.html
Kug3lis has joined #crystal-lang
<jokke> thanks
vivus-ignis has joined #crystal-lang
Kug3lis has quit [Client Quit]
<jokke> @firejox: how would i make a qube root of a bigint
<jokke> i only see ** defined for int
<RX14> Well you can do ** 1/3
hako_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <firejox> @jokke sorry I don know very well for that
Philpax has joined #crystal-lang
Philpax_ has joined #crystal-lang
<jokke> no problem
Philpax has quit [Ping timeout: 268 seconds]
Nulldata has joined #crystal-lang
<Nulldata> Seems like Crystal doesn't like recursively typed Hashes
<Nulldata> I assume this is a bug?
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
Nulldata has quit [Quit: ChatZilla 0.9.93 [Firefox 50.1.0/20161208153507]]
Yxhuvud has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
bjz has quit [Ping timeout: 246 seconds]
bjz_ has joined #crystal-lang
hako has joined #crystal-lang
vivus-ignis has quit [Ping timeout: 256 seconds]
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
literal has joined #crystal-lang
Philpax_ has quit [Ping timeout: 258 seconds]
hako has joined #crystal-lang
Ven has joined #crystal-lang
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hako has joined #crystal-lang
A124 has quit [Ping timeout: 258 seconds]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has quit [Ping timeout: 265 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 258 seconds]
<FromGitter> <firejox> well, I change it to unions, then it works :smile:
rkeene has joined #crystal-lang
Ven has joined #crystal-lang
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hako has joined #crystal-lang
hako has quit [Client Quit]
<crystal-gh> [crystal] asterite pushed 3 new commits to master: https://git.io/vMLaI
<crystal-gh> crystal/master 60d9c4f Ary Borenszweig: Let `method_missing` work with `with ... yield`. Fixes #1808
<crystal-gh> crystal/master 5e9bf6e Ary Borenszweig: Add `IO#skip_to_end`
<crystal-gh> crystal/master a712c7e Ary Borenszweig: Let `IO#skip` raise if there aren't enough bytes
<DeBot> https://github.com/crystal-lang/crystal/issues/1808 (question, dsl with method_missing and self yield)
Ven has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 246 seconds]
A124 has joined #crystal-lang
<travis-ci> crystal-lang/crystal#60d9c4f (master - Let `method_missing` work with `with ... yield`. Fixes #1808): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187745291
<DeBot> https://github.com/crystal-lang/crystal/issues/1808 (question, dsl with method_missing and self yield)
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
mgarciaisaia has joined #crystal-lang
<FromGitter> <martinium> ```barDataResp["results"].each {|key, value| p "#{key} : #{value}”}```
<FromGitter> <martinium> I am trying to print out a json object mapping the json values to a string and have it display each with colon “:” in between
<FromGitter> <martinium> this code above prints the colon at the end of the JSON object
<FromGitter> <martinium> any ideas how to fix?
<FromGitter> <martinium> I get this output for any ticker I enter: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5866a68bc895451b7539dea2]
<FromGitter> <martinium> I want it instead to look like symbol : GOOG
<FromGitter> <martinium> instead of the json look
<BlaXpirit> martinium, hm I don't understand the problem. maybe you should isolate this to a small reproducible code snippet
<BlaXpirit> one thing i see is.. maybe you just need to use `puts` instead of `p`
Ven has joined #crystal-lang
<FromGitter> <martinium> when I use puts it prints it all left to right and includes a bunch of forward slashes
<BlaXpirit> ok.. so it's probably JSON::Any at work
<FromGitter> <martinium> actually this time it did ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5866a86cc895451b7539f16f]
<FromGitter> <martinium> still has the curlies etc
<BlaXpirit> i don't understand how your code can produce this output
<BlaXpirit> please isolate it to a reproducible snippet. in the process you might find the problem yourself
<FromGitter> <martinium> this is all within a function
<FromGitter> <martinium> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5866a8e5c895451b7539f3d8]
<BlaXpirit> i need code that i can run
<FromGitter> <martinium> gotcha
<FromGitter> <martinium> there an apikey involved you’d have to get a free one for it to work for you
<FromGitter> <martinium> I’ll try and figure it out
<BlaXpirit> martinium, oh .. no, it's not necessary to run your exact code. you can put the json in a file
<BlaXpirit> martinium, I suppose that the problem is `key` is not what you think it is
<BlaXpirit> the variable `key` actually stores the whole JSON dictionary at the moment where you try to print it
<BlaXpirit> but why that happens is a different question
<FromGitter> <martinium> I’ve tried using string interpolation
<FromGitter> <martinium> nothing works
<BlaXpirit> look, i'm just guessing here. but perhaps results is an array of dictionaries
<BlaXpirit> and you just iterate over the array using `each`
<BlaXpirit> so indeed `key` ends up being the dictionaries, one at a time
<BlaXpirit> and `value` is nil
<BlaXpirit> because iterating over an array only yields one item ,not two
<FromGitter> <martinium> you are correct
<FromGitter> <martinium> results is an array of dictionaries
<BlaXpirit> martinium, so uh.. i've identified the problem. do you see it?
<FromGitter> <martinium> value doesn’t do anything since it is nil
<FromGitter> <martinium> key is the dictionaries
<BlaXpirit> well yes
Ven has quit [Ping timeout: 256 seconds]
<FromGitter> <martinium> any ideas on how to print each key:value with my own formatting for each dictionary in key?
<FromGitter> <martinium> that’s what my goal is
<BlaXpirit> martinium, for that you must iterate over the dictionary, not over the array of dictionaries
<FromGitter> <martinium> is there a modifier I can use that would let me iterate on the dictionary itself
<FromGitter> <martinium> I am thinking like barDataResp[“results”].key.each?
<FromGitter> <martinium> to isolate the dictionary itself
<FromGitter> <martinium> in order to iterate
Ven has joined #crystal-lang
<crystal-gh> [crystal] asterite opened pull request #3806: Add XML.write and XML::Writer (master...feature/xml_writer) https://git.io/vMLKx
<DeBot> https://github.com/crystal-lang/crystal/pull/3806 (Add XML.write and XML::Writer)
Ven has quit [Ping timeout: 245 seconds]
<BlaXpirit> martinium, problem+fix https://carc.in/#/r/1if8
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 256 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 246 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMLP3
<crystal-gh> crystal/master 49aa490 Ary Borenszweig: Compiler: set require location so `--prelude` can work with relative files
matp_ has joined #crystal-lang
LastWhisper____ has joined #crystal-lang
dtzu has quit [Read error: Connection reset by peer]
matp has quit [Ping timeout: 260 seconds]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
Ven has joined #crystal-lang
vivus-ignis has joined #crystal-lang
dtzu has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vMLME
<crystal-gh> crystal/master a62dff3 Ary Borenszweig: Fixed #3805: incorrect type for generic instance whose generic type has subclasses
<DeBot> https://github.com/crystal-lang/crystal/issues/3805 (Generics inheritance problem)
<travis-ci> crystal-lang/crystal#49aa490 (master - Compiler: set require location so `--prelude` can work with relative files): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187769392
Ven has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<travis-ci> crystal-lang/crystal#a62dff3 (master - Fixed #3805: incorrect type for generic instance whose generic type has subclasses): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187776781
<DeBot> https://github.com/crystal-lang/crystal/issues/3805 (Generics inheritance problem)
Ven has quit [Ping timeout: 258 seconds]
<crystal-gh> [crystal] maiha opened pull request #3808: Fixed `Iterator#uniq` with block (master...fix-iterator-uniq) https://git.io/vMLSU
<DeBot> https://github.com/crystal-lang/crystal/pull/3808 (Fixed `Iterator#uniq` with block)
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 245 seconds]
<FromGitter> <jots_twitter> any idea how to have kemal's logger log client IP and referer along with what it logs now? @sdogruyol ?
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
<FromGitter> <andyfleming> What would be an equivalent way to accomplish this in crystal: https://gist.github.com/andyfleming/ab5baa85704f8e205996ab44795ef501 ?
<FromGitter> <martinium> @BlaXpirit thanks a bunch. I would have never guessed that would be the way
<FromGitter> <andyfleming> Here’s what I’ve got so far: https://gist.github.com/andyfleming/f9e2a858579a7561f1d0248f1fffb693
vivus-ignis has quit [Ping timeout: 265 seconds]
<RX14> @andyfleming you need to use channels
<RX14> replace the results array with a channel
<RX14> or use the parallel macro
<RX14> but that doesn't explain the p[rinciples
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
Ven has quit [Ping timeout: 264 seconds]
willl has joined #crystal-lang
<willl> Good blog post today
<RX14> @andyfleming you would need to recieve from that channel 3 times to get every result
<RX14> also req() returns a IO
<RX14> so the channel.send should fail
Ven has joined #crystal-lang
<FromGitter> <andyfleming> What’s the easiest way to convert IO to a string?
<FromGitter> <andyfleming> Is there an IO.to_s that will wait for completion of the IO?
<RX14> io.gets_to_end
<FromGitter> <andyfleming> So this would theoretically work: https://gist.github.com/andyfleming/f9e2a858579a7561f1d0248f1fffb693
<RX14> no because you need a space after url before the : :)
<RX14> line 3
<RX14> also the channel is the wrong type
<FromGitter> <andyfleming> Oh, the channel type needs to be based on the message type?
<FromGitter> <andyfleming> `Channel(String).new`?
<RX14> yes
<FromGitter> <andyfleming> That makes sense
<RX14> also i was wrong
<RX14> response.body is a String
<RX14> response.body_io is an IO
Ven has quit [Ping timeout: 246 seconds]
<FromGitter> <andyfleming> Gotcha, cool
<RX14> i'm sure there are some compile errors there
<RX14> but you get the general idea
<FromGitter> <andyfleming> There are
<FromGitter> <andyfleming> Says req isn’t defined
<crystal-gh> [crystal] TheLonelyGhost opened pull request #3809: Replace /bin/bash with /bin/sh (master...replace-bash-with-sh) https://git.io/vMLdN
<DeBot> https://github.com/crystal-lang/crystal/pull/3809 (Replace /bin/bash with /bin/sh)
Ven has joined #crystal-lang
<FromGitter> <andyfleming> I think I’m missing something obvious. https://gist.github.com/andyfleming/f9e2a858579a7561f1d0248f1fffb693
Ven has quit [Read error: Connection reset by peer]
<RX14> yes
<RX14> maybe
<FromGitter> <andyfleming> haha, thanks :-P
<RX14> well
<FromGitter> <jots_twitter> @andyfleming : does this help? https://gist.github.com/jots/53aeebaf3dd5603728f3cdb6f0714ed2
<RX14> this works
<RX14> the reason it doesn't work in a module
<RX14> is because the `req` method is not defined as a method on the module
<RX14> the module class*
<FromGitter> <andyfleming> would I need to write it as def `self.req`?
<FromGitter> <andyfleming> `def self.req`*
<RX14> maybe
<RX14> but
<RX14> never mind
<FromGitter> <andyfleming> I’ll skip the module for now
<crystal-gh> [crystal] asterite closed pull request #3808: Fixed `Iterator#uniq` with block (master...fix-iterator-uniq) https://git.io/vMLSU
<DeBot> https://github.com/crystal-lang/crystal/pull/3808 (Fixed `Iterator#uniq` with block)
soveran has joined #crystal-lang
Ven has joined #crystal-lang
triangles has joined #crystal-lang
triangles2 has quit [Ping timeout: 268 seconds]
<FromGitter> <andyfleming> Is there any way to preserve the order of the requests?
<RX14> uhh
<RX14> not easilly
<RX14> actually not
<Papierkorb> Array(Response?) and #each_with_index ?
<RX14> that only ensures the start order
<RX14> not that a whole HTTP request is sent before the next connects
Raimondii has joined #crystal-lang
Ven has quit [Ping timeout: 246 seconds]
Raimondi has quit [Ping timeout: 244 seconds]
<FromGitter> <jots_twitter> @andyfleming : modified it to return a hash so you can process results in order you want: https://gist.github.com/jots/53aeebaf3dd5603728f3cdb6f0714ed2
Raimondii is now known as Raimondi
<FromGitter> <andyfleming> I’ll give that approach a try too. My latest (working, aside from order) was https://gist.github.com/andyfleming/f9e2a858579a7561f1d0248f1fffb693
Philpax has joined #crystal-lang
<FromGitter> <andyfleming> are futures a feature a crystal?
<RX14> well it's in the stdlib
<FromGitter> <andyfleming> or is that part of the http client?
<RX14> but it's rarely used
Ven has joined #crystal-lang
<FromGitter> <andyfleming> I don’t see it in the API docs anywhere
<RX14> it's :nodoc:
<FromGitter> <andyfleming> As in “not yet documented” or as in “undocumented feature, not recommended for use”
<RX14> well
<RX14> i don't know why actually
<FromGitter> <jots_twitter> I hope "not yet documented" as I prefer them to plain channels. Here is the code for them: https://github.com/crystal-lang/crystal/blob/master/src/concurrent/future.cr
<RX14> well
<RX14> they serve entirely different uses
<RX14> channels are much more generally useful
<RX14> futures are implemented using channels
Ven has quit [Ping timeout: 252 seconds]
<FromGitter> <TheLonelyGhost> quick question: where might I find docs on the libraries required for compiling the crystal compiler? I'm working on porting it to alpine linux for use with docker, if at all possible.
<RX14> there's a list on the wiki page iirc
<FromGitter> <TheLonelyGhost> ah, perfect. I keep forgetting there's a wiki
<FromGitter> <TheLonelyGhost> thanks!
<FromGitter> <andyfleming> It’s a bit hard to follow the `each_with_index`docs. Shouldn’t I be doing `["/one", "/two", "/three"].each_with_index do |offset, endpoint|`?
<RX14> no
<RX14> other way around
<RX14> it has an example
<RX14> ["Alice", "Bob"].each_with_index do |user, i|
<FromGitter> <jots_twitter> mnemonic: index is last in "each_with_index"
<FromGitter> <andyfleming> Not on the array API doc
<RX14> it doesn't exist in the array API doc
<RX14> each_with_index is on Enumerable
<RX14> where were you reading?
<FromGitter> <andyfleming> Array and Iterable
<RX14> iterable?
<RX14> thats the wrong one
<RX14> ok
<RX14> Iterable is to do with Iterators
<RX14> which is a seperate topic
<RX14> you then have Indexable and Enumberable
<FromGitter> <andyfleming> Gotcha
<RX14> Enumberable simply assumes you have a `each` method
<RX14> Indexable requires `size` and to be able to access by position
<RX14> and provides an `each` method
<FromGitter> <andyfleming> which would be fine for an array, right?
<FromGitter> <andyfleming> it implements both from what I can tell
<RX14> yes
<RX14> the docs you want are on Enumberable
<RX14> if you go on the api docs for array
<FromGitter> <andyfleming> Yeah, found the ones you were talking about
<FromGitter> <andyfleming> Next question: If I have an `Array({Int32, String})`, can I sort by the first value of the tuple with `sort_by`?
<RX14> and search for each_with_index you can find it
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
<RX14> don't use sort_by
<FromGitter> <andyfleming> It looks like `a.sort_by { |x, y| y }` would work
<RX14> no
<RX14> that's the correct usage for sort
<RX14> sort_by is different
<RX14> and also the wrong usage for sort
<RX14> array.sort { |a, b| a[0] <=> b[0] }
<RX14> what is happening there is you get given a and b which are elements of the array
<RX14> and you're asked to compare them
<RX14> most things implement Comparable
<RX14> which means you can use <=> operator to compare them
<RX14> so we assume that case, and extract the first element of each item we're asked to compare and compare them using <=>
mgarciaisaia has quit [Quit: Leaving.]
<RX14> you can read the docs on ,=> in the Comparable docs
<RX14> <=>*
<FromGitter> <andyfleming> Yup, standard spaceship operator
<FromGitter> <andyfleming> Cool with that
<RX14> oh ok
<FromGitter> <andyfleming> So, I now have an exmaple for both futures and channels: https://gist.github.com/andyfleming/f9e2a858579a7561f1d0248f1fffb693
<RX14> second one is longer and very slightly less efficient :)
<RX14> actually the comparison isn't really fair
<RX14> also stop using tabs in crystal :/
<FromGitter> <andyfleming> Sorry, it is my sublime defaults (normally use webstorm)
<FromGitter> <andyfleming> also copying back and forth with gist
<FromGitter> <andyfleming> Here’s a more concise example for futures that aligns better with the other https://gist.github.com/andyfleming/f9e2a858579a7561f1d0248f1fffb693
onionhammer has quit [Ping timeout: 246 seconds]
<TheGillies> Just read newest blog article, stoked that parallism is next goal woo
<travis-ci> crystal-lang/crystal#cbaccf8 (master - Fixed `Iterator#uniq` with block): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/187804582
Ven has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang