deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
Human_G33k has joined #crystal-lang
ua has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 256 seconds]
f1refly has joined #crystal-lang
chachasmooth has quit [Ping timeout: 256 seconds]
chachasmooth has joined #crystal-lang
duane has quit [Read error: No route to host]
chachasmooth has quit [Ping timeout: 264 seconds]
chachasmooth has joined #crystal-lang
duane has joined #crystal-lang
postmodern has joined #crystal-lang
<postmodern>
anyone know how spectator does equality checks? for some reason it's claiming the yielded Array of Tuples does not match Array of Tuples parsed from YAML. When I write the same code in a .cr file and build that, i get the expected results.
<Rounin>
postmodern: I'm no crystal expert, but wouldn't T be the type?
<Rounin>
Seems like some kind of generic method
<Rounin>
I'm going off my Java knowledge here, but it seems like you might do something like... Pointer(Integer).malloc(100), say
<Rounin>
Kind of sort of maybe
<postmodern>
but does Pointer(T).malloc return Pointer(T) or Slice(T), since malloc is typically given a size (really a length)
<Rounin>
postmodern: Ah, I see... Beyond me, I didn't know Crystal had malloc
<postmodern>
according to `p Pointer(T).malloc(N)` returns a Pointer(T)
oddp has joined #crystal-lang
<oprypin>
postmodern: if u want slice, do Slice.new
<postmodern>
oprypin, i was more interested in the fact the documentation wasn't totally accurate; and it should be totally accurate.
<oprypin>
postmodern: yea the documentation doesn't specify return types very often. tell me something new
<postmodern>
could i fix that by just adding ` : Pointer(T)`? I can submit a PR if it's that simple.
<postmodern>
(trying to avoid submitting incorrect PRs
<oprypin>
such particular PR sounds good
duane has joined #crystal-lang
<FromGitter>
<asterite> postmodern: it's a primitive and we forgot to add a return type, but it returns `Pointer(T)`. Maybe I tried adding a return type and it didn't work, I can't remember
<FromGitter>
<Blacksmoke16> mm id say if you already have the builder just use that
<FromGitter>
<Blacksmoke16> the first one essentially just does the 2nd
<FromGitter>
<dscottboggs_gitlab> yeah that's where I've been leaning, but I was also thinking like ⏎ ⏎ ```"some text".to_yaml builder ⏎ some_hash.to_yaml builder``` ⏎ ⏎ Might seem more consistent [https://gitter.im/crystal-lang/crystal?at=5f2c6d6571c83e6f0fc285cf]
<FromGitter>
<Blacksmoke16> True
duane has quit [Ping timeout: 240 seconds]
renich has quit [Quit: Leaving.]
renich has joined #crystal-lang
postmodern has joined #crystal-lang
renich has quit [Quit: Leaving.]
<postmodern>
what is the crystal equivalent of `.map(&Foo.method(:bar))`?
<FromGitter>
<Blacksmoke16> mm what is it doing?
<FromGitter>
<Blacksmoke16> calling `Foo.method` with the argument of `:bar` for each value in the array?
<postmodern>
getting the method .bar on Foo and passing it as a block.
<FromGitter>
<Blacksmoke16> uhh
<FromGitter>
<Blacksmoke16> im going to say you cant do that
<FromGitter>
<Blacksmoke16> would have to be like `.map { |item| Foo.bar item }`
<postmodern>
so no fancy silliness like `.map(&->Foo.bar)` or something
<postmodern>
wow the fact that protected methods can be called by objects within the same namespace is nice
<postmodern>
exactly what i was looking for to hide an internal API that other objects need to call back to
<FromGitter>
<Blacksmoke16> there is `&->` but idt it works for methods off another type other than whats on local scope
<FromGitter>
<dscottboggs_gitlab> postmodern, if the type of the value yielded by `#map` in this case is `Foo` then you could do `map &.bar`
<FromGitter>
<dscottboggs_gitlab> but in Crystal methods are tightly bound to their defining structure/class -- you can't, for example do `someClass.method.call(someObject, arg)` like you can in javascript
<postmodern>
dscottboggs_gitlab, but would that be considered good/readable crystal?
<postmodern>
also really liking the fact that you can combine protected methods with overriding to hide more complex internal methods of the same name. Very handy!
<FromGitter>
<dscottboggs_gitlab> I agree!
<FromGitter>
<Blacksmoke16> `private` would be better if that method is only intended to be call within `self`
<FromGitter>
<dscottboggs_gitlab> I agree with that as well, I almost never use `protected`
<FromGitter>
<Blacksmoke16> i use it a lot at work in PHP land, mainly since private methods are available to child types
<FromGitter>
<Blacksmoke16> aren't*
<postmodern>
protected is really handy in my usecase where i have this Device class that defines internal API methods that invoke ioctls on an fd, but I also have other classes like Buffer that have to invoke internal methods from Device
<postmodern>
i could technically move the Buffer specific ioctls into the Buffer class, and use @device.fd, but i feel like keeping that low-level ioctl logic in Device is better. protected lets me hide the messy API details
<FromGitter>
<Blacksmoke16> :shrug;
<FromGitter>
<Blacksmoke16> and related to thing i made last night, im making it shard. I think its pretty neat :p
<FromGitter>
<Blacksmoke16> ill put something on the forums when its done in next day or so
<yxhuvud>
postmodern, I trust you saw the sections on proc_literal and blocks_and_procs in the gitbook?