jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
davic has joined #crystal-lang
<FromGitter> <Dan-Do> There is compile error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f7524312e334178fbf9a58b]
<FromGitter> <Blacksmoke16> Makes sense
<FromGitter> <Dan-Do> The compiler doesn't respect the `if`, does it?
<FromGitter> <Blacksmoke16> It does, but not like that
<FromGitter> <Blacksmoke16> Try using a local variable first
<FromGitter> <Dan-Do> Thanks, got it :)
<FromGitter> <Dan-Do> Oops, wait. Isn't foo a local variable? The above code is reduced in one file called `test.cr`
<FromGitter> <Blacksmoke16> I mean the value of foo.b
<FromGitter> <Dan-Do> Now it works, thanks again
mistergibson has joined #crystal-lang
mistergibson has quit [Remote host closed the connection]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
_whitelogger has joined #crystal-lang
Liothen has quit [Ping timeout: 244 seconds]
Liothen has joined #crystal-lang
<FromGitter> <throwaway4rust> Any news about windows support?
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> best bet would be to follow https://github.com/crystal-lang/crystal/issues/5430
Human_G33k has quit [Ping timeout: 272 seconds]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Read error: Connection reset by peer]
HumanG33k has joined #crystal-lang
renich has joined #crystal-lang
<oprypin> @throwaway4rust: nothing happening
renich has quit [Quit: Leaving.]
renich has joined #crystal-lang
renich has quit [Ping timeout: 258 seconds]
Stephie- is now known as Stephie
renich has joined #crystal-lang
renich has quit [Ping timeout: 260 seconds]
renich has joined #crystal-lang
<FromGitter> <error256> Hello. Is this a bug or how do I use `cons_pair`? ⏎ ⏎ ```[1, 2, 3].each.cons_pair.each{ |x, y| x + y }``` ⏎ ⏎ `Error: no overload matches 'Int32#+' with type (Int32 | Iterator::Stop)` [https://gitter.im/crystal-lang/crystal?at=5f763a8efcce3e6c18e7a8dd]
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Enumerable.html#each_cons_pair(&:T,T-%3E_):Nil-instance-method
<FromGitter> <error256> I want to get an Iterator, it's just a minimum example with `each`. It could as well be ⏎ ⏎ ```[1, 2, 3].each.cons_pair.to_a``` ⏎ ⏎ `Error: no overload matches 'Array(Tuple(Int32, Int32))#<<' with type Tuple(Int32 | Iterator::Stop, Int32 | Iterator::Stop)` [https://gitter.im/crystal-lang/crystal?at=5f763b25daf8227643af3893]
<FromGitter> <Blacksmoke16> i think the problem is `x` or `y` can be `Iterator::Stop` that means there are no more values
<FromGitter> <Blacksmoke16> hence the error in the first example
<FromGitter> <error256> I understand this, but I think `Iterator::Stop` isn't supposed to be inside the tuple? When the source iterator ends, the result ends too.
<FromGitter> <error256> If `Iterator::Stop` in the tuple is normal, in what case can it happen?
<FromGitter> <Blacksmoke16> i wouldnt think it would be an actual value, but the var that gets yielded is typed as either `Int32` or that
<FromGitter> <Blacksmoke16> so id imagine thats the problem
<FromGitter> <Blacksmoke16> maybe worth a forum post?
<FromGitter> <Blacksmoke16> actually
<FromGitter> <error256> I'd say it's worth a GitHub issue because the type clearly isn't what it should be. I'm just not exactly sure where the bug is... `cons_pair` is declared as `def cons_pair : Iterator({T, T})`, so at this point `T` already is `Int32 | Iterator::Stop`. Is it `each`?...
<FromGitter> <Blacksmoke16> first guess is that `value` isnt a `Stop` since its a `Tuple`?
<FromGitter> <Blacksmoke16> hence why this is only an issue with the iterator version of `cons_pair` not `each_cons_pair`
<FromGitter> <Blacksmoke16> idk, im not super familiar with iterators
<FromGitter> <error256> Same for ⏎ ⏎ ```it : Iterator({Int32, Int32}) = [1, 2, 3].each.cons_pair ⏎ it.to_a``` ⏎ ⏎ So is it something with type deduction?.. I'll think more about it tomorrow. [https://gitter.im/crystal-lang/crystal?at=5f7640f8717f8e4eb5f29c08]
<FromGitter> <Blacksmoke16> `#to_a` uses `#each`
alexherbo29 has joined #crystal-lang
<FromGitter> <Blacksmoke16> my guess is that since the value is a tuple its getting past the check that should break and prevent the stop value from being yielded
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo29 is now known as alexherbo2
<FromGitter> <Daniel-Worrall> It's an `Iterator(Tuple(T, T))`, yes, but that Iterator can return `Tuple(T, T) | Iterator::Stop::INSTANCE` on `#next`
<FromGitter> <Daniel-Worrall> which is what `#each` and therefore `#to_a` use
<FromGitter> <Blacksmoke16> yup
<raz> yup
<raz> i would assume #each_cons_pair exists exactly because of that oddity
<FromGitter> <Blacksmoke16> i tend to agree, whats the point of using an iterator in this context?
<FromGitter> <Blacksmoke16> but still not ideal
<raz> iterating over pairs can be useful sometimes.
<FromGitter> <Blacksmoke16> sure, but based on the examples provided so far its not giving any benefit
<raz> well, i imagine he simplified them for the sake of irc ;)
<FromGitter> <Blacksmoke16> `arr.each.each_cons.each do |a, b|` isnt any better than `arr.each_cons_pair do |a, b`
<FromGitter> <Blacksmoke16> probably :p
<raz> but yup agree. the two methods seem to do the exact same. having to remember to use the right one depending on the input isn't nice, but doesn't seem too terrible to me
<FromGitter> <Blacksmoke16> normally the convention is there is a non block overload that returns the iterator
<FromGitter> <Blacksmoke16> wonder why this one is diff (of if there even is a reason)
<raz> well, tuples are always weird
<raz> tuples and symbols
<FromGitter> <Blacksmoke16> boo symbols
<raz> i have a theory tho! <einstein-face>
<raz> so, Iterator::Stop seems to leak into both sides of the tuple: Tuple(Int32 | Iterator::Stop, Int32 | Iterator::Stop)
<raz> i suspect, it might be using *two* each'es under the hood. kinda like the double slit experiment.
<raz> </einstein-face>
<raz> hm actually, no that doesn't make sense :P
<FromGitter> <Blacksmoke16> swaps positions which spreads the union would be my guess
<raz> oh right, of course
<raz> any element could be the last element
<raz> i wonder if you could confuse it by adding Iterator::Stop to an odd position in the input array :P
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo29 is now known as alexherbo2
renich has quit [Remote host closed the connection]
riffraff169 has quit [Quit: Leaving.]
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
alexherbo24 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo24 is now known as alexherbo2
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang