00:00
<
FromGitter >
<andyfleming> Fair enough. I'll open up a separate PR for getter/setter examples to at least start a discussion there.
00:01
<
RX14 >
i'm pretty sure there's an example around
00:04
<
FromGitter >
<andyfleming> What is a property? and how is it different than an instance variable?
00:04
<
RX14 >
@andyfleming you need newlines between your methods in your PR otherwise it looks ugly
00:04
<
RX14 >
a property is a macro
00:05
<
RX14 >
if you look at the docs you can see the expanded code
00:05
<
RX14 >
it defines an instance variable
00:05
<
RX14 >
and a getter/setter pair for the instance variable
00:05
<
FromGitter >
<andyfleming> Done. Also, I guess the other examples might need the methods added as well
00:06
<
RX14 >
doing object.foo = "bar" in crystal is actually dispatching to the method foo= with the argument "bar"
00:06
<
FromGitter >
<andyfleming> Gotcha
00:06
<
FromGitter >
<andyfleming> So the options are effectively: getter/setter/property AKA both
00:07
<
RX14 >
so the macro defines `def foo=` which recieves the argument and sets the instance variable
00:07
<
RX14 >
like for example java getters/setters
00:07
<
RX14 >
property is just getter + setter
00:07
<
FromGitter >
<andyfleming> :+1:
00:07
<
FromGitter >
<andyfleming> (that's a thumbs up in case it doesn't come through on IRC :D)
00:08
<
RX14 >
it shows up as `:+1:`
00:08
<
RX14 >
if that shows up as text in gitter
00:08
<
RX14 >
so I got the message :)
00:10
<
FromGitter >
<andyfleming> Would the latter be better?
00:12
<
RX14 >
in real code
00:12
<
RX14 >
not for the docs
00:14
<
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.
00:14
<
FromGitter >
<andyfleming> It could be BEAUTIFUL!
00:15
<
RX14 >
i think "new, initialize and annlocate" should be merged into "methods and instance variables" somewhat too
00:15
<
RX14 >
that area of docs keeps coming up as a pain point
00:16
<
FromGitter >
<andyfleming> Yeah
00:16
<
FromGitter >
<andyfleming> `allocate` seems like an advanced topic that shouldn’t be mixed in with creation of class instances
00:16
<
FromGitter >
<andyfleming> (though a mention/link might be appropriate)
00:26
<
crystal-gh >
[crystal] ysbaddaden closed pull request #3798: Fix: Socket.unix (master...fix-socket-unix)
https://git.io/vMInp
00:39
<
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
00:43
<
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"} })`?
00:44
<
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
00:44
<
FromGitter >
<andyfleming> A hash would be `{ “AbortDate” => {“type” => "timestamp"} }`
00:44
<
FromGitter >
<taylorfinnell> sorry named tuple
00:46
<
FromGitter >
<andyfleming> It’s not too bad to write it as a string
00:46
<
FromGitter >
<taylorfinnell> that is nice, thank you!
00:48
<
FromGitter >
<andyfleming> Sorry, technically for JSON it still needs to be in quotes, but it’s not too bad
00:48
<
FromGitter >
<taylorfinnell> Sorry one sec, I don't think I am being clear
00:50
<
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
00:51
<
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.
00:51
<
FromGitter >
<taylorfinnell> ```JSON.mapping(shapes: Hash(String, Shape))```
00:51
<
FromGitter >
<taylorfinnell> is close, but I lose access to the hash key name in the Shape class
00:57
<
FromGitter >
<andyfleming> Sorry, I’m not familiar enough with `JSON.mapping` to be of much help
00:58
<
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
00:58
matp_ has joined #crystal-lang
00:59
matp has quit [Read error: Connection reset by peer]
00:59
<
FromGitter >
<bcardiff> Don't be afraid. Mapping is coded on top of pullparser and is really flexible
01:03
<
FromGitter >
<taylorfinnell> Thanks! Will look at pull parser :)
02:02
martinium has joined #crystal-lang
02:13
Yxhuvud has quit [Ping timeout: 260 seconds]
02:36
triangles2 has joined #crystal-lang
02:39
triangles has quit [Ping timeout: 265 seconds]
03:32
bcardiff has quit [Quit: bcardiff]
03:48
Kug3lis has joined #crystal-lang
03:51
Kug3lis is now known as Kug3lis_off
03:54
Kug3lis has joined #crystal-lang
04:10
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
04:11
martinium has quit [Ping timeout: 246 seconds]
04:21
pcc54 has joined #crystal-lang
04:22
pcc54 has quit [Client Quit]
04:52
_whitelogger has joined #crystal-lang
05:00
triangles has joined #crystal-lang
05:03
triangles2 has quit [Ping timeout: 265 seconds]
05:19
pawnbox has quit [Ping timeout: 248 seconds]
05:53
pawnbox has joined #crystal-lang
06:16
bjz has joined #crystal-lang
06:25
matp_ has quit [Read error: Connection reset by peer]
06:26
matp has joined #crystal-lang
06:26
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
06:45
bjz has joined #crystal-lang
07:20
matp has quit [Read error: Connection reset by peer]
07:21
matp_ has joined #crystal-lang
07:25
pawnbox has quit [Remote host closed the connection]
07:26
pawnbox has joined #crystal-lang
07:30
pawnbox has quit [Ping timeout: 258 seconds]
07:49
soveran has joined #crystal-lang
07:49
soveran has joined #crystal-lang
07:49
soveran has quit [Changing host]
07:53
pawnbox has joined #crystal-lang
08:00
hako has joined #crystal-lang
08:28
soveran has quit [Remote host closed the connection]
09:00
Kug3lis has joined #crystal-lang
09:16
<
FromGitter >
<radarek> Is there a way to check if method is defined? Any macro?
09:18
<
FromGitter >
<radarek> <BlaXpirit> thanks!
09:24
matp_ has quit [Quit: ZZzzzZz...]
09:25
vivus-ignis has joined #crystal-lang
09:25
vivus-ignis has quit [Client Quit]
09:28
soveran has joined #crystal-lang
09:30
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:39
Kug3lis has joined #crystal-lang
09:40
Kug3lis has quit [Client Quit]
09:43
matp has joined #crystal-lang
09:45
soveran has quit [Remote host closed the connection]
09:46
pawnbox has quit [Remote host closed the connection]
09:46
pawnbox has joined #crystal-lang
09:48
soveran has joined #crystal-lang
09:48
soveran has joined #crystal-lang
09:48
soveran has quit [Changing host]
09:51
pawnbox has quit [Remote host closed the connection]
09:51
pawnbox has joined #crystal-lang
09:51
pawnbox has quit [Remote host closed the connection]
10:01
Raimondii has joined #crystal-lang
10:04
Raimondi has quit [Ping timeout: 260 seconds]
10:04
Raimondii is now known as Raimondi
10:12
bjz_ has joined #crystal-lang
10:13
bjz has quit [Ping timeout: 258 seconds]
10:16
pawnbox has joined #crystal-lang
10:23
Yxhuvud has joined #crystal-lang
10:24
damireh has joined #crystal-lang
10:24
soveran has quit [Ping timeout: 246 seconds]
10:32
etrepat has joined #crystal-lang
10:33
etrepat has left #crystal-lang [#crystal-lang]
10:42
Kug3lis has joined #crystal-lang
10:43
damireh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
10:44
Kug3lis has quit [Client Quit]
10:47
damireh has joined #crystal-lang
10:53
<
RX14 >
The new year's resolutions blog post was nice
10:54
<
FromGitter >
<andyfleming> Oooo, haven’t read it yet!
10:57
<
FromGitter >
<radarek> I read it and future for crystal looks very promising! :D
10:57
<
txdv >
i looked into my crystal
10:57
vivus-ignis has joined #crystal-lang
10:59
vivus-ignis has quit [Read error: Connection reset by peer]
11:00
<
FromGitter >
<andyfleming> lol
11:00
<
FromGitter >
<andyfleming> It was a good post. 1.0 here we come!
11:04
<
RX14 >
Well I wouldn't get to attached to that 2017 release date
11:04
<
RX14 >
New year's resolutions are often broken
11:04
<
FromGitter >
<andyfleming> Gotta have goals xD
11:04
<
RX14 >
Not that we shouldn't try
11:05
<
FromGitter >
<andyfleming> I think it’s important for aspects like paralellism to take the time to get it right.
11:05
<
RX14 >
I would rather release a 1.0 we can be proud of in 2018 than stick to a 2017 goal
11:05
<
FromGitter >
<andyfleming> Yeah, agreed
11:06
vivus-ignis has joined #crystal-lang
11:37
hako_ has joined #crystal-lang
11:41
hako has quit [Ping timeout: 268 seconds]
11:44
Kug3lis has joined #crystal-lang
11:47
Philpax has joined #crystal-lang
11:50
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
11:51
Kug3lis has joined #crystal-lang
11:52
Kug3lis has quit [Client Quit]
11:56
triangles2 has joined #crystal-lang
11:59
Kug3lis has joined #crystal-lang
11:59
triangles has quit [Ping timeout: 258 seconds]
12:01
Kug3lis has quit [Client Quit]
12:04
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
12:05
bjz has joined #crystal-lang
12:12
Kug3lis has joined #crystal-lang
12:14
Kug3lis has quit [Client Quit]
12:19
<
RX14 >
@firejox looks like a big to me, at least the error message
12:30
<
crystal-gh >
crystal/master a8783e2 Andy Fleming: Removing "In progress" label
12:31
Kug3lis has joined #crystal-lang
12:36
<
RX14 >
That's why I said it was a bug
12:37
<
RX14 >
Do you get an error with that code you linked?
12:42
<
FromGitter >
<firejox> @RX14 It got another strange error, but not the error in my first linked
12:43
<
RX14 >
It would be helpful if you linked it...
12:43
<
RX14 >
Though I might not be around to help you.
12:43
Yxhuvud has quit [Ping timeout: 252 seconds]
12:48
Philpax has quit [Ping timeout: 268 seconds]
12:48
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
12:54
vivus-ignis has quit [Ping timeout: 258 seconds]
13:08
pawnbox has quit [Remote host closed the connection]
13:09
pawnbox has joined #crystal-lang
13:10
pawnbox has quit [Remote host closed the connection]
13:10
pawnbox has joined #crystal-lang
13:14
Kug3lis has joined #crystal-lang
13:17
<
jokke >
is there a bignum lib for crystal?
13:17
Kug3lis has quit [Client Quit]
13:19
Kug3lis has joined #crystal-lang
13:21
vivus-ignis has joined #crystal-lang
13:21
Kug3lis has quit [Client Quit]
13:23
<
jokke >
@firejox: how would i make a qube root of a bigint
13:23
<
jokke >
i only see ** defined for int
13:30
<
RX14 >
Well you can do ** 1/3
13:34
hako_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:35
<
FromGitter >
<firejox> @jokke sorry I don know very well for that
13:36
Philpax has joined #crystal-lang
13:39
Philpax_ has joined #crystal-lang
13:41
Philpax has quit [Ping timeout: 268 seconds]
13:44
Nulldata has joined #crystal-lang
13:45
<
Nulldata >
Seems like Crystal doesn't like recursively typed Hashes
13:48
<
Nulldata >
I assume this is a bug?
13:49
Kug3lis has joined #crystal-lang
13:52
Kug3lis has quit [Client Quit]
13:58
Nulldata has quit [Quit: ChatZilla 0.9.93 [Firefox 50.1.0/20161208153507]]
14:06
Yxhuvud has joined #crystal-lang
14:21
Kug3lis has joined #crystal-lang
14:24
Kug3lis has quit [Client Quit]
14:32
bjz has quit [Ping timeout: 246 seconds]
14:32
bjz_ has joined #crystal-lang
14:59
hako has joined #crystal-lang
15:28
vivus-ignis has quit [Ping timeout: 256 seconds]
15:30
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
15:32
literal has joined #crystal-lang
15:33
Philpax_ has quit [Ping timeout: 258 seconds]
15:33
hako has joined #crystal-lang
16:05
Ven has joined #crystal-lang
16:07
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:10
hako has joined #crystal-lang
16:16
A124 has quit [Ping timeout: 258 seconds]
16:18
Kug3lis has joined #crystal-lang
16:26
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:29
Ven has quit [Ping timeout: 265 seconds]
16:32
Ven has joined #crystal-lang
16:45
Ven has quit [Ping timeout: 246 seconds]
16:52
Ven has joined #crystal-lang
16:59
Ven has quit [Ping timeout: 258 seconds]
17:01
<
FromGitter >
<firejox> well, I change it to unions, then it works :smile:
17:10
rkeene has joined #crystal-lang
17:32
Ven has joined #crystal-lang
17:37
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
17:39
hako has joined #crystal-lang
17:39
hako has quit [Client Quit]
17:45
<
crystal-gh >
crystal/master 60d9c4f Ary Borenszweig: Let `method_missing` work with `with ... yield`. Fixes #1808
17:45
<
crystal-gh >
crystal/master 5e9bf6e Ary Borenszweig: Add `IO#skip_to_end`
17:45
<
crystal-gh >
crystal/master a712c7e Ary Borenszweig: Let `IO#skip` raise if there aren't enough bytes
17:45
Ven has quit [Ping timeout: 246 seconds]
17:52
Ven has joined #crystal-lang
18:01
Ven has quit [Ping timeout: 246 seconds]
18:01
A124 has joined #crystal-lang
18:12
Ven has joined #crystal-lang
18:13
Ven has quit [Read error: Connection reset by peer]
18:15
mgarciaisaia has joined #crystal-lang
18:23
<
FromGitter >
<martinium> ```barDataResp["results"].each {|key, value| p "#{key} : #{value}”}```
18:24
<
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
18:24
<
FromGitter >
<martinium> this code above prints the colon at the end of the JSON object
18:24
<
FromGitter >
<martinium> any ideas how to fix?
18:25
<
FromGitter >
<martinium> I want it instead to look like symbol : GOOG
18:25
<
FromGitter >
<martinium> instead of the json look
18:31
<
BlaXpirit >
martinium, hm I don't understand the problem. maybe you should isolate this to a small reproducible code snippet
18:31
<
BlaXpirit >
one thing i see is.. maybe you just need to use `puts` instead of `p`
18:32
Ven has joined #crystal-lang
18:32
<
FromGitter >
<martinium> when I use puts it prints it all left to right and includes a bunch of forward slashes
18:32
<
BlaXpirit >
ok.. so it's probably JSON::Any at work
18:33
<
FromGitter >
<martinium> still has the curlies etc
18:33
<
BlaXpirit >
i don't understand how your code can produce this output
18:34
<
BlaXpirit >
please isolate it to a reproducible snippet. in the process you might find the problem yourself
18:35
<
FromGitter >
<martinium> this is all within a function
18:36
<
BlaXpirit >
i need code that i can run
18:37
<
FromGitter >
<martinium> gotcha
18:37
<
FromGitter >
<martinium> there an apikey involved you’d have to get a free one for it to work for you
18:37
<
FromGitter >
<martinium> I’ll try and figure it out
18:38
<
BlaXpirit >
martinium, oh .. no, it's not necessary to run your exact code. you can put the json in a file
18:39
<
BlaXpirit >
martinium, I suppose that the problem is `key` is not what you think it is
18:39
<
BlaXpirit >
the variable `key` actually stores the whole JSON dictionary at the moment where you try to print it
18:40
<
BlaXpirit >
but why that happens is a different question
18:40
<
FromGitter >
<martinium> I’ve tried using string interpolation
18:40
<
FromGitter >
<martinium> nothing works
18:41
<
BlaXpirit >
look, i'm just guessing here. but perhaps results is an array of dictionaries
18:41
<
BlaXpirit >
and you just iterate over the array using `each`
18:41
<
BlaXpirit >
so indeed `key` ends up being the dictionaries, one at a time
18:41
<
BlaXpirit >
and `value` is nil
18:41
<
BlaXpirit >
because iterating over an array only yields one item ,not two
18:42
<
FromGitter >
<martinium> you are correct
18:42
<
FromGitter >
<martinium> results is an array of dictionaries
18:44
<
BlaXpirit >
martinium, so uh.. i've identified the problem. do you see it?
18:45
<
FromGitter >
<martinium> value doesn’t do anything since it is nil
18:45
<
FromGitter >
<martinium> key is the dictionaries
18:45
<
BlaXpirit >
well yes
18:45
Ven has quit [Ping timeout: 256 seconds]
18:45
<
FromGitter >
<martinium> any ideas on how to print each key:value with my own formatting for each dictionary in key?
18:45
<
FromGitter >
<martinium> that’s what my goal is
18:46
<
BlaXpirit >
martinium, for that you must iterate over the dictionary, not over the array of dictionaries
18:47
<
FromGitter >
<martinium> is there a modifier I can use that would let me iterate on the dictionary itself
18:47
<
FromGitter >
<martinium> I am thinking like barDataResp[“results”].key.each?
18:48
<
FromGitter >
<martinium> to isolate the dictionary itself
18:48
<
FromGitter >
<martinium> in order to iterate
18:52
Ven has joined #crystal-lang
19:00
<
crystal-gh >
[crystal] asterite opened pull request #3806: Add XML.write and XML::Writer (master...feature/xml_writer)
https://git.io/vMLKx
19:01
Ven has quit [Ping timeout: 245 seconds]
19:03
Ven has joined #crystal-lang
19:17
Ven has quit [Ping timeout: 256 seconds]
19:23
Ven has joined #crystal-lang
19:30
Ven has quit [Ping timeout: 246 seconds]
19:31
<
crystal-gh >
crystal/master 49aa490 Ary Borenszweig: Compiler: set require location so `--prelude` can work with relative files
19:44
matp_ has joined #crystal-lang
19:45
LastWhisper____ has joined #crystal-lang
19:45
dtzu has quit [Read error: Connection reset by peer]
19:46
matp has quit [Ping timeout: 260 seconds]
19:59
Kug3lis has joined #crystal-lang
20:00
Kug3lis has quit [Client Quit]
20:02
Ven has joined #crystal-lang
20:08
vivus-ignis has joined #crystal-lang
20:09
dtzu has joined #crystal-lang
20:13
<
crystal-gh >
crystal/master a62dff3 Ary Borenszweig: Fixed #3805: incorrect type for generic instance whose generic type has subclasses
20:16
Ven has quit [Ping timeout: 246 seconds]
20:21
Ven has joined #crystal-lang
20:29
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
20:46
Ven has quit [Ping timeout: 258 seconds]
20:47
<
crystal-gh >
[crystal] maiha opened pull request #3808: Fixed `Iterator#uniq` with block (master...fix-iterator-uniq)
https://git.io/vMLSU
20:50
Ven has joined #crystal-lang
21:01
Ven has quit [Ping timeout: 245 seconds]
21:05
<
FromGitter >
<jots_twitter> any idea how to have kemal's logger log client IP and referer along with what it logs now? @sdogruyol ?
21:09
Ven has joined #crystal-lang
21:16
Ven has quit [Ping timeout: 260 seconds]
21:30
Ven has joined #crystal-lang
21:45
<
FromGitter >
<martinium> @BlaXpirit thanks a bunch. I would have never guessed that would be the way
21:54
vivus-ignis has quit [Ping timeout: 265 seconds]
21:54
<
RX14 >
@andyfleming you need to use channels
21:55
<
RX14 >
replace the results array with a channel
21:55
<
RX14 >
or use the parallel macro
21:55
<
RX14 >
but that doesn't explain the p[rinciples
21:57
Kug3lis has joined #crystal-lang
21:59
Kug3lis has quit [Client Quit]
22:02
Ven has quit [Ping timeout: 264 seconds]
22:02
willl has joined #crystal-lang
22:02
<
willl >
Good blog post today
22:05
<
RX14 >
@andyfleming you would need to recieve from that channel 3 times to get every result
22:05
<
RX14 >
also req() returns a IO
22:05
<
RX14 >
so the channel.send should fail
22:09
Ven has joined #crystal-lang
22:11
<
FromGitter >
<andyfleming> What’s the easiest way to convert IO to a string?
22:12
<
FromGitter >
<andyfleming> Is there an IO.to_s that will wait for completion of the IO?
22:13
<
RX14 >
io.gets_to_end
22:14
<
RX14 >
no because you need a space after url before the : :)
22:15
<
RX14 >
also the channel is the wrong type
22:15
<
FromGitter >
<andyfleming> Oh, the channel type needs to be based on the message type?
22:15
<
FromGitter >
<andyfleming> `Channel(String).new`?
22:15
<
FromGitter >
<andyfleming> That makes sense
22:15
<
RX14 >
also i was wrong
22:16
<
RX14 >
response.body is a String
22:16
<
RX14 >
response.body_io is an IO
22:17
Ven has quit [Ping timeout: 246 seconds]
22:17
<
FromGitter >
<andyfleming> Gotcha, cool
22:18
<
RX14 >
i'm sure there are some compile errors there
22:18
<
RX14 >
but you get the general idea
22:18
<
FromGitter >
<andyfleming> There are
22:18
<
FromGitter >
<andyfleming> Says req isn’t defined
22:27
<
crystal-gh >
[crystal] TheLonelyGhost opened pull request #3809: Replace /bin/bash with /bin/sh (master...replace-bash-with-sh)
https://git.io/vMLdN
22:28
Ven has joined #crystal-lang
22:29
Ven has quit [Read error: Connection reset by peer]
22:40
<
FromGitter >
<andyfleming> haha, thanks :-P
22:41
<
RX14 >
the reason it doesn't work in a module
22:42
<
RX14 >
is because the `req` method is not defined as a method on the module
22:42
<
RX14 >
the module class*
22:42
<
FromGitter >
<andyfleming> would I need to write it as def `self.req`?
22:43
<
FromGitter >
<andyfleming> `def self.req`*
22:46
<
FromGitter >
<andyfleming> I’ll skip the module for now
22:48
<
crystal-gh >
[crystal] asterite closed pull request #3808: Fixed `Iterator#uniq` with block (master...fix-iterator-uniq)
https://git.io/vMLSU
22:48
soveran has joined #crystal-lang
22:49
Ven has joined #crystal-lang
22:49
triangles has joined #crystal-lang
22:53
triangles2 has quit [Ping timeout: 268 seconds]
22:56
<
FromGitter >
<andyfleming> Is there any way to preserve the order of the requests?
22:57
<
RX14 >
actually not
22:57
<
Papierkorb >
Array(Response?) and #each_with_index ?
22:57
<
RX14 >
that only ensures the start order
22:57
<
RX14 >
not that a whole HTTP request is sent before the next connects
22:59
Raimondii has joined #crystal-lang
23:01
Ven has quit [Ping timeout: 246 seconds]
23:02
Raimondi has quit [Ping timeout: 244 seconds]
23:02
Raimondii is now known as Raimondi
23:04
Philpax has joined #crystal-lang
23:07
<
FromGitter >
<andyfleming> are futures a feature a crystal?
23:08
<
RX14 >
well it's in the stdlib
23:08
<
FromGitter >
<andyfleming> or is that part of the http client?
23:08
<
RX14 >
but it's rarely used
23:08
Ven has joined #crystal-lang
23:08
<
FromGitter >
<andyfleming> I don’t see it in the API docs anywhere
23:08
<
RX14 >
it's :nodoc:
23:09
<
FromGitter >
<andyfleming> As in “not yet documented” or as in “undocumented feature, not recommended for use”
23:13
<
RX14 >
i don't know why actually
23:15
<
RX14 >
they serve entirely different uses
23:15
<
RX14 >
channels are much more generally useful
23:15
<
RX14 >
futures are implemented using channels
23:16
Ven has quit [Ping timeout: 252 seconds]
23:19
<
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.
23:19
<
RX14 >
there's a list on the wiki page iirc
23:20
<
FromGitter >
<TheLonelyGhost> ah, perfect. I keep forgetting there's a wiki
23:20
<
FromGitter >
<TheLonelyGhost> thanks!
23:21
<
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|`?
23:22
<
RX14 >
other way around
23:22
<
RX14 >
it has an example
23:23
<
RX14 >
["Alice", "Bob"].each_with_index do |user, i|
23:23
<
FromGitter >
<jots_twitter> mnemonic: index is last in "each_with_index"
23:23
<
FromGitter >
<andyfleming> Not on the array API doc
23:23
<
RX14 >
it doesn't exist in the array API doc
23:24
<
RX14 >
each_with_index is on Enumerable
23:24
<
RX14 >
where were you reading?
23:24
<
FromGitter >
<andyfleming> Array and Iterable
23:25
<
RX14 >
thats the wrong one
23:25
<
RX14 >
Iterable is to do with Iterators
23:25
<
RX14 >
which is a seperate topic
23:26
<
RX14 >
you then have Indexable and Enumberable
23:26
<
FromGitter >
<andyfleming> Gotcha
23:26
<
RX14 >
Enumberable simply assumes you have a `each` method
23:26
<
RX14 >
Indexable requires `size` and to be able to access by position
23:26
<
RX14 >
and provides an `each` method
23:26
<
FromGitter >
<andyfleming> which would be fine for an array, right?
23:26
<
FromGitter >
<andyfleming> it implements both from what I can tell
23:27
<
RX14 >
the docs you want are on Enumberable
23:27
<
RX14 >
if you go on the api docs for array
23:27
<
FromGitter >
<andyfleming> Yeah, found the ones you were talking about
23:27
<
FromGitter >
<andyfleming> Next question: If I have an `Array({Int32, String})`, can I sort by the first value of the tuple with `sort_by`?
23:27
<
RX14 >
and search for each_with_index you can find it
23:28
Ven has joined #crystal-lang
23:29
Ven has quit [Read error: Connection reset by peer]
23:30
<
RX14 >
don't use sort_by
23:30
<
FromGitter >
<andyfleming> It looks like `a.sort_by { |x, y| y }` would work
23:30
<
RX14 >
that's the correct usage for sort
23:30
<
RX14 >
sort_by is different
23:30
<
RX14 >
and also the wrong usage for sort
23:31
<
RX14 >
array.sort { |a, b| a[0] <=> b[0] }
23:31
<
RX14 >
what is happening there is you get given a and b which are elements of the array
23:31
<
RX14 >
and you're asked to compare them
23:31
<
RX14 >
most things implement Comparable
23:31
<
RX14 >
which means you can use <=> operator to compare them
23:32
<
RX14 >
so we assume that case, and extract the first element of each item we're asked to compare and compare them using <=>
23:32
mgarciaisaia has quit [Quit: Leaving.]
23:32
<
RX14 >
you can read the docs on ,=> in the Comparable docs
23:32
<
FromGitter >
<andyfleming> Yup, standard spaceship operator
23:32
<
FromGitter >
<andyfleming> Cool with that
23:34
<
RX14 >
second one is longer and very slightly less efficient :)
23:35
<
RX14 >
actually the comparison isn't really fair
23:36
<
RX14 >
also stop using tabs in crystal :/
23:38
<
FromGitter >
<andyfleming> Sorry, it is my sublime defaults (normally use webstorm)
23:38
<
FromGitter >
<andyfleming> also copying back and forth with gist
23:38
onionhammer has quit [Ping timeout: 246 seconds]
23:40
<
TheGillies >
Just read newest blog article, stoked that parallism is next goal woo
23:48
Ven has joined #crystal-lang
23:49
soveran has quit [Remote host closed the connection]
23:54
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
23:56
Ven has joined #crystal-lang