ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | 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
<FromGitter> <jrei:matrix.org> I'll just rewrite the whole history
<FromGitter> <jrei:matrix.org> otherwise with bisect it is going to be painful
<oprypin> good idea
<FromGitter> <jrei:matrix.org> got: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60345b0e7ba8124e54820075]
<FromGitter> <jrei:matrix.org> `We cannot bisect more!`
<FromGitter> <jrei:matrix.org> I'm out of trying
_whitelogger has joined #crystal-lang
johnny101 has quit [Read error: Connection reset by peer]
_ht has joined #crystal-lang
<FromGitter> <HertzDevil> is there a reason `while` expressions don't return the value in a `break`
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
hendursaga has joined #crystal-lang
hendursa1 has quit [Ping timeout: 268 seconds]
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
<FromGitter> <naqvis> I believe that's intentional and reference doc states the same ⏎ ⏎ > A while's type is always Nil. ⏎ ⏎ Crystal isn't the only one, Scala `while` expression also always return `Unit` [https://gitter.im/crystal-lang/crystal?at=6034d28f9ba13e72e44a1449]
<FromGitter> <naqvis> if one need to return value from looping expression then `loop` construct is the choice
<FromGitter> <HertzDevil> that's different
<FromGitter> <HertzDevil> `loop` opens a new scope and `while` doesn't
<FromGitter> <naqvis> true, as `loop` is just a stdlib method a wrapper against `while` which invokes the block provided
<FromGitter> <oprypin:matrix.org> @HertzDevil: https://github.com/crystal-lang/crystal/issues/1277
<FromGitter> <HertzDevil> ooo
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <alexherbo2> how to check if stdin is eof?
<FromGitter> <alexherbo2> I want to know if it is empty
<straight-shoota> try to read from it
<FromGitter> <alexherbo2> `input = STDIN.gets_to_end` and check `input.empty?` ?
<FromGitter> <alexherbo2> it will block I think, if there is nothing
<FromGitter> <alexherbo2> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60350652a8c6a778482a78a6]
<FromGitter> <Blacksmoke16> does `STDIN.blocking = false` do anything?
<straight-shoota> if that call blocks, stdin is open and waiting for input
<straight-shoota> you can't know if it has any content unless it's closed
<straight-shoota> for example, when stdin is a tty and you run your program, the shell will forward everything you write to the program
<straight-shoota> you can write something directly or after three hours
<straight-shoota> the program trying to read from stdin will block until you write something
<straight-shoota> or close the stream
<FromGitter> <asterite> @HertzDevil I didn't know in `while` the `break` gave the value to it, that's why it doesn't behave like in Ruby. But it could/should
<FromGitter> <HertzDevil> okay
<FromGitter> <asterite> I actually think `break` with a value is very useful, to avoid having a separate boolean like "found" that you initialize to `false` and then set in the middle of the loop just before a `break`
<FromGitter> <HertzDevil> that's what i was thinking, but also if the whole `while` is in a condition (e.g. from a macro) then perhaps we could do flow typing with it
<FromGitter> <HertzDevil> actually when i did the `TypeFilters` thing i thought of extending it to arbitrary nested `if`s
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=603520d1a37fc1784c3e3db1]
<FromGitter> <asterite> That snippet doesn't work already?
<FromGitter> <RespiteSage> So the perceived benefits of `break` taking a value and using it as the return type of the loop is 1) to be more like Ruby, and 2) to type less?
<FromGitter> <naqvis> I would say its 1), as Rubyism takes all precedence :P. Though I still can't get my head off around returning a value from a while loop. As after having this feature implemented while will always return a Union of `Type | Nil`
<straight-shoota> Yeah but this is just like `each |i| break i if ... end`
<straight-shoota> the return type is also `typeof(i) | Nil`
<straight-shoota> It would only make sense that `break` can receive arguments just like `next` or `return`. They're all similar concepts
<straight-shoota> and it already works in blocks, so why not with `while`
<FromGitter> <asterite> Also `while` without `break`, or with `break` without a value will still have the `Nil` type. It's just when you break with a value that it will be different
<straight-shoota> exactly
<straight-shoota> it's just concistent with all existing behaviour
dostoyevsky has quit [Ping timeout: 246 seconds]
dostoyevsky has joined #crystal-lang
tskalyo has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
hpyc9 has quit [Quit: 420]
hpyc9 has joined #crystal-lang
hendursaga has quit [Ping timeout: 268 seconds]
_ht has quit [Remote host closed the connection]
hendursaga has joined #crystal-lang
r0bby has quit [Ping timeout: 265 seconds]
sz0 has quit [Ping timeout: 264 seconds]
r0bby has joined #crystal-lang
sz0 has joined #crystal-lang
<FromGitter> <jrei:matrix.org> strange question: where are the spec method in the API docs?
<FromGitter> <jrei:matrix.org> I mean, `it`, `describe`
<FromGitter> <jrei:matrix.org> thanks!
<FromGitter> <jrei:matrix.org> how can they be in the top level too?
<FromGitter> <jrei:matrix.org> *usable
<straight-shoota> `include Spec::Methods`
<FromGitter> <jrei:matrix.org> I didn't know we can include directly on the top level! `extend SomeModule` seems to do the same
<FromGitter> <jrei:matrix.org> logical, because we can define `def self.foo; end` on the top level
<FromGitter> <jrei:matrix.org> Ho, indeed, the modules https://crystal-lang.org/api/master/toplevel.html are both defined in `Included Modules` and `Extended Modules` O.O
dom96 has quit [*.net *.split]
dom96 has joined #crystal-lang