ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <watzon> Yeah since IO is the abstract base class for all IO::* classes it will catch any of them
<FromGitter> <watzon> Does removing the first part of the union fix your problem?
<FromGitter> <Blacksmoke16> @watzon https://crystal-lang.org/api/master/Time.html#shift(*,years:Int=0,months:Int=0,weeks:Int=0,days:Int=0,hours:Int=0,minutes:Int=0,seconds:Int=0,nanoseconds:Int=0)-instance-method
<FromGitter> <watzon> Ooh look at that
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
<FromGitter> <Daniel-Worrall> I think shards don't update when tags are made. ⏎ The shard is listed as 0.1.0 on their `shard.yml` but hasn't released any versions, you install it with `shards install`. ⏎ The shard releases new commits, then tags and releases 0.1.0. ⏎ You now specify version: ~> 0.1.0 in your `shard.yml` ⏎ `shards install` won't update the lockfile (maybe this part is intentional) and install from the commit
<FromGitter> ... you had locked it at previously ... [https://gitter.im/crystal-lang/crystal?at=5dc0d279a3f0b17849eb32dd]
<FromGitter> <watzon> It only updates based on releases, otherwise you have to specify a branch or tag manually
<FromGitter> <Daniel-Worrall> if you don't specify a release, it takes the master and calls it a version
<FromGitter> <Daniel-Worrall> so if you "update" from that to the released version, it doesn't actually update
<FromGitter> <Blacksmoke16> if you dont specify a release im pretty sure it just uses the latest one
<FromGitter> <Daniel-Worrall> That's not what I'm saying the problem is. It's misidentifying an old commit as a release tag and not overwriting the lib folder
teardown has quit [Ping timeout: 276 seconds]
duane has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Can shards pull from private repos
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> I believe so. Shards uses git, so you would have to have a key configured probably.
duane has quit [Ping timeout: 268 seconds]
teardown has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> Is there something equivalent to PHP's `mysqli_real_escape_string` for Crystal?
ht_ has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> i guess ` update table set field = ?` is probably ideal. i'll just use this as i think it's safer (prepared statements?)
go|dfish has quit [Ping timeout: 250 seconds]
ht_ has quit [Quit: ht_]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Remote host closed the connection]
DTZUZO has joined #crystal-lang
go|dfish has joined #crystal-lang
raz has joined #crystal-lang
<raz> small suggestion: it would be great if the api-docs would have a clickable version-switcher at the top (because google returns links to pretty much random api versions depending on what you search for)
OvermindDL1 has quit [Quit: Connection closed for inactivity]
alexherbo2 has joined #crystal-lang
<raz> @vlazar oh yea... it's a bit of a rabbit hole.
<raz> looks promising though
gangstacat has quit [Remote host closed the connection]
gangstacat has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
MasterdonX has quit [Ping timeout: 265 seconds]
duane has joined #crystal-lang
MasterdonX has joined #crystal-lang
duane has quit [Ping timeout: 252 seconds]
duane has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <bajro17> how to create new file
<FromGitter> <bajro17> I try File.write("foo","bar")
<FromGitter> <bajro17> it dont work
<FromGitter> <tenebrousedge> did you try to open it for writing?
<FromGitter> <tenebrousedge> and what do you mean "it dont work"?
<FromGitter> <bajro17> I'm sorry it work
<FromGitter> <bajro17> but it save in root
<FromGitter> <bajro17> I dont see it
<FromGitter> <bajro17> because I was inside folder
<FromGitter> <tenebrousedge> k
<FromGitter> <wontruefree> @ImAHopelessDev_gitlab We will try and record it is a new system so recordings are not guaranteed
<FromGitter> <bajro17> if I declare variable without class
<FromGitter> <bajro17> like somestring: String
<FromGitter> <bajro17> how can I change it inside each loop
<FromGitter> <tenebrousedge> for a string you probably want to use `StringBuilder`
<FromGitter> <tenebrousedge> alternately, use `join` with a block argument
Yxhuvud has quit [Read error: Connection reset by peer]
<FromGitter> <bajro17> I fix it like this
<FromGitter> <bajro17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc19955e886fb5aa25b8fd5]
<FromGitter> <tenebrousedge> ew
<FromGitter> <bajro17> @tenebrousedge its ugly?
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <tenebrousedge> there's almost always something better than `each` ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc19a52e886fb5aa25b94f3]
<FromGitter> <bajro17> I like this way
<FromGitter> <bajro17> ```th = "<th>%s</th>" ⏎ string = fieldsArray.join(&->th.%(String))``` [https://gitter.im/crystal-lang/crystal?at=5dc19b3510bd4128a1c56cfe]
<FromGitter> <bajro17> but I dont understand it well
<FromGitter> <tenebrousedge> it's a printf-style format string. `"<th>%s</th>` % "foo" #=> "<th>foo</th>"`
<FromGitter> <tenebrousedge> ```"<tr><td>%s</td><td>%s</td></tr>" % ["foo", "bar"] #=> "<tr><td>foo</td><td>bar</td></tr>"```
<FromGitter> <tenebrousedge> There's a similar syntax for named elements that takes a hash
<FromGitter> <tenebrousedge> %s means that you're passing in a string. There's also %d for integers, and %f for floats. You can control how many significant digits get printed if you need to
<FromGitter> <tenebrousedge> the `&->object.methodName(ArgumentClass)` syntax is just a short way to reference a method defined on a given object
<FromGitter> <bajro17> Thank you so much brother
<FromGitter> <bajro17> so good explanation
<FromGitter> <bajro17> I appreciate it <3
<FromGitter> <tenebrousedge> anytime
Yxhuvud has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <vlazar> > ``` ⏎ > th = "<th>%s</th>" ⏎ > string = fieldsArray.join(&->th.%(String)) ⏎ > ``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5dc1a91be1c5e915083b4cb4]
<FromGitter> <tenebrousedge> the `&.` syntax should do you there
<FromGitter> <vlazar> it would be
<FromGitter> <vlazar> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1a96010bd4128a1c5d46f]
<FromGitter> <vlazar> but that's with `map`
<FromGitter> <vlazar> so it creates arrays on each step
<FromGitter> <tenebrousedge> you probably shouldn't be defining class methods like that
<FromGitter> <tenebrousedge> I mean, you can, but this isn't Elixir
<FromGitter> <vlazar> yeah, I'm just wanted to come up with the Crystal's equivalent for this Ruby code from link above ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1aa23e886fb5aa25c0f1b]
<FromGitter> <tenebrousedge> `map` is a thing. But you'd probably do `batch.map &.parse.normalize.transform`
<FromGitter> <tenebrousedge> or `.try &.parse.try &.normalize.try & .transform` depending
<FromGitter> <tenebrousedge> if you really really want to use class methods for this, then the `&->` syntax you had would be correct
<FromGitter> <tenebrousedge> Ruby `then` -> Crystal `try`, for the most part
<FromGitter> <tenebrousedge> and `&->object.method(Arg)` is equivalent to Ruby's `method`, or seemingly this short syntax
<hightower2> oo good one
<FromGitter> <Daniel-Worrall> I have some pseudo code here. Is there a way I can move the common code so that it's not repeated, isn't its own method and isn't run on the else case ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1acd17477946bad33a530]
<FromGitter> <Daniel-Worrall> and also without another redundant comparison
<FromGitter> <tenebrousedge> use a proc?
<FromGitter> <Daniel-Worrall> Ooh, that'd do
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <vlazar> @tenebrousedge Ah, thanks! You are right ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1b06afb4dab784a6cac1e]
alexherbo27 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 276 seconds]
<FromGitter> <asterite> I think I'd prefer to write it like `.try { |x| Parse.call(x) }`, etc.
<FromGitter> <jacobsun> When you pass range to array#select methods, is the begin and end means array index or the order in natural?
<FromGitter> <jacobsun> ```ary.select!(3..7) ⏎ ary # => [6, 4]``` [https://gitter.im/crystal-lang/crystal?at=5dc1b7053d669b28a03e96a9]
<FromGitter> <jacobsun> ```ary.select!(3..7) ⏎ ary # => [6, 4]`````` [https://gitter.im/crystal-lang/crystal?at=5dc1b72fe886fb5aa25c706d]
<FromGitter> <vlazar> yeah, if types wan't be required it would be nice
<FromGitter> <vlazar> like
<FromGitter> <vlazar> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1b7cb9c39821509eb4191]
<FromGitter> <vlazar> or even
<FromGitter> <vlazar> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1b88114d55a3785ddb1f3]
<FromGitter> <tenebrousedge> I like Ruby's `method` method
<FromGitter> <tenebrousedge> word_list.select(&DICTIONARY.method(:include?))
<FromGitter> <tenebrousedge> the nice thing is that it's just a normal method, not a special syntax
<FromGitter> <tenebrousedge> so you can call other methods on it ⏎ ⏎ ```('a'..'z').select(&"ACEG".downcase.method(:include?))``` [https://gitter.im/crystal-lang/crystal?at=5dc1b9ce7477946bad3400e4]
<FromGitter> <asterite> Yeah, but I mean, the only thing that you save there is having to choose a name for the arg, and maybe a few characters. I'm also pretty sure in Ruby `method` and then `&` are slower than the arg+call approach, the same way using `&:downcase` is slower than `|x| x.downcase`
<FromGitter> <asterite> we could always introduce named block args like in Ruby... `select { "ACEG".downcase.include?(@1) }`
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <vlazar> yes, Ruby's `&` with `method` is much slower (10x slower in article, 20x slower for me with code from article)
<FromGitter> <tenebrousedge> `method` is slower, but it allows you to manipulate the object
<FromGitter> <tenebrousedge> and manipulate it outside the loop
<FromGitter> <tenebrousedge> which named block args would not do
<FromGitter> <vlazar> @asterite it's now `select { "ACEG".downcase.include?(_1) }` in Ruby :)
<FromGitter> <vlazar> the `@1` syntax was changed to `_1` and there was a lot of interesting thoughts in https://bugs.ruby-lang.org/issues/15723
<FromGitter> <asterite> Oh, I'm glad they changed the syntax, the `@` was very noisy
<FromGitter> <vlazar> yeah, me too, but numbered params still feel a bit weird
<FromGitter> <vlazar> > If it will be multiple params @1, @2, etc. Can we also have @ aliasing @1? I think it's going to be a common use case to just have the one param.
<FromGitter> <vlazar> probably a good point
<FromGitter> <vlazar> I also like this part
<FromGitter> <vlazar> This makes the common 95% case even more readable/beautiful: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1c077e1c5e915083bffc1]
<FromGitter> <asterite> It's interesting because `_1` is a valid variable name in Ruby, so they are just introducing a breaking change
<FromGitter> <asterite> It's also interesting to learn that they added `...` as a way to forward all arguments
<FromGitter> <asterite> (unrelated, but still...)
<FromGitter> <watzon> +1 for named arg blocks
<FromGitter> <vlazar> comment by Matz ⏎ ⏎ > The problem is introducing `it` or `this` could break existing code. That is the problem. Numbered parameters are a compromise to simplify block expression without breaking compatibility.
<FromGitter> <vlazar> `it` as for implicit(first) block argument
<FromGitter> <watzon> If anyone has thoughts on #8441 please make them known. My friend @Zenohate is probably going to PR the Float::Printer so that it uses the Ryu algorithm over Grisu3, which should offer a significant performance increase
<DeBot> https://github.com/crystal-lang/crystal/issues/8441 (Use Ryu algorithm for floating point to string conversation)
<FromGitter> <vlazar> blocks arguments thingy reminded these 2 forgotten discussions of forum https://forum.crystal-lang.org/t/rfc-with-yield-replacement/386 https://forum.crystal-lang.org/t/rfc-within-a-block/417/16
alexherbo273 has joined #crystal-lang
alexherbo27 has quit [Ping timeout: 240 seconds]
<hightower3> Does Crystal have something like atexit ?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/toplevel.html#at_exit(&handler:Int32,Exception?-%3E):Nil-class-method
<hightower3> Cool!
<Yxhuvud> asterite: while _1 is a valid variable name in ruby, variables starting with _ has the meaning that they are not used (you won't get a warning if you don't use them, as opposed to normal local variables). so the risk of conflict is pretty small.
<FromGitter> <asterite> I see
<FromGitter> <bajro17> What mode I can use to create folder
<FromGitter> <bajro17> I try File.write("template/index/index.html", string, mode: "a")
<FromGitter> <bajro17> but it dont create folder
sorcus has quit [Ping timeout: 264 seconds]
<FromGitter> <tenebrousedge> You probably want `FileUtils.mkdir_p`
<FromGitter> <Blacksmoke16> `filename will be created if it does not already exist.` i guess that doesn't include creating directories as well
<FromGitter> <tenebrousedge> I wouldn't expect it to
<FromGitter> <bararchy> got this pesky bug
<FromGitter> <bararchy> @bcardiff ^ I managed to reproduce it 💃
<FromGitter> <ilanpillemer> whats the max size of an array?
<FromGitter> <Blacksmoke16> prob `Int32::MAX`
<FromGitter> <tenebrousedge> so yes, `Int32::MAX`
<FromGitter> <ilanpillemer> is any kind of collection able to accept a size of Uint32.MAX?
<FromGitter> <tenebrousedge> not sure. What do you need it for?
<FromGitter> <ilanpillemer> too hold upto UInt32 items
<FromGitter> <tenebrousedge> what do you need it for?
<FromGitter> <ilanpillemer> a puzzle
<FromGitter> <ilanpillemer> in which I have up to UInt32 items
<FromGitter> <ilanpillemer> so a simple way is to count them in one pass
<FromGitter> <ilanpillemer> hhmm
<FromGitter> <ilanpillemer> maybe unix sort will help
<FromGitter> <tenebrousedge> probably the puzzle is designed so that you have to have a clever answer
<FromGitter> <ilanpillemer> I am sure there is a clever answer
<FromGitter> <ilanpillemer> I was just wondering if Crystal was powerful enough to not need a clever answer
<FromGitter> <ilanpillemer> trying to see if unix pipes and filters work
<FromGitter> <christopherzimmerman> Is there a way to have a proc as an instance variable that calls functions that use other instance variables? Something like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1df3810bd4128a1c78176]
<FromGitter> <christopherzimmerman> Right now it just returns junk values
<FromGitter> <tenebrousedge> maybe you want a `getter` with a block?
<FromGitter> <bajro17> is it possible to replace string with string
<FromGitter> <tenebrousedge> @bajro17 like `gsub` or like `replace`?
<FromGitter> <bajro17> "test {{test}} {{test1}}".gsub({"{{test}}": "something", "{{test1}}": "anothersomething"})
<FromGitter> <tenebrousedge> @bajro17 use the named sprintf syntax
<FromGitter> <kinxer> @christopherzimmerman Why not just have a class/struct as your instance variable and instantiate a different one depending on what you need?
<FromGitter> <tenebrousedge> ```"I have %<apples>s apples" % {apples: 4} ``` ⏎ ⏎ @bajro17 [https://gitter.im/crystal-lang/crystal?at=5dc1e054e1c5e915083ce8c4]
<FromGitter> <bajro17> Because I read from file
<FromGitter> <bajro17> I have stuff like {{title}} {{body}} etc
<FromGitter> <tenebrousedge> @kinxer @christopherzimmerman you could do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1e0ea3d669b28a03fcb06]
<FromGitter> <tenebrousedge> @bajro17 ⏎ ⏎ ```"I have {{foo}} bars." % {"{{foo}}" => "foo"}``` [https://gitter.im/crystal-lang/crystal?at=5dc1e1302f8a03435740edb6]
<FromGitter> <tenebrousedge> er
sorcus has joined #crystal-lang
<FromGitter> <kinxer> I was thinking of something like this: https://carc.in/#/r/7yn1
<FromGitter> <kinxer> I think that's the Strategy Pattern (https://en.wikipedia.org/wiki/Strategy_pattern).
<FromGitter> <kinxer> Btw, does IRC get the rendered Markdown somehow or just the raw text before rendering?
<FromGitter> <tenebrousedge> I don't see what difference it makes to use a class vs. a proc
<FromGitter> <tenebrousedge> but w/e
<FromGitter> <kinxer> I think it's cleaner if you have a lot of logic. Also, proc syntax is ugly.
<FromGitter> <christopherzimmerman> The getter would work, but then I'm still checking that flag each time I call next. I was hoping I could set it just once.
<FromGitter> <tenebrousedge> @christopherzimmerman the block is automatically memoized
<FromGitter> <tenebrousedge> it's only evaluated once
<FromGitter> <kinxer> Very cool. I didn't know the compiler did that.
<FromGitter> <christopherzimmerman> Hmm, I wonder why the performance is so different then for me. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1e2749825bd6bac322f89]
<FromGitter> <christopherzimmerman> The first is with the getter, the second is manually setting the correct path.
<FromGitter> <kinxer> Would you please label which is which?
<FromGitter> <tenebrousedge> lots of things affect micro-benchmarks
<FromGitter> <kinxer> ^
<FromGitter> <kinxer> Also, make sure you're compiling with `--release`.
<FromGitter> <kinxer> I doubt the memoization happens if you compile without it.
<FromGitter> <christopherzimmerman> Those are both with release, I'm trying a benchmark where nothing can get closured
<FromGitter> <bajro17> @tenebrousedge thank you so much
<FromGitter> <bajro17> this % is so useful
<FromGitter> <bajro17> just I dont know use it like you :)
<FromGitter> <bajro17> I make it perfect
<FromGitter> <tenebrousedge> you're very welcome :)
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1e3a99c39821509ec8c45]
<FromGitter> <christopherzimmerman> I'm seeing about the same performance with getter vs manual even when I remove any closured variables.
<FromGitter> <bajro17> I love this programming language and this community
<FromGitter> <bajro17> I never regret because I come here
<FromGitter> <christopherzimmerman> If I check the value at each iteration of the loop, the performance still matches the getter: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1e468a03ae1584f73d4a6]
<FromGitter> <christopherzimmerman> I'm assuming the memoization happens for both structs and classes?
<FromGitter> <tenebrousedge> well if you're doing it in the initializer it should be evaluated once, either way?
<FromGitter> <tenebrousedge> can you throw your code in a gist?
teardown has quit [Ping timeout: 240 seconds]
<FromGitter> <christopherzimmerman> I would need to include my entire shard :/, and its a mess right now. I'll see if I can create a minimal example.
<FromGitter> <christopherzimmerman> I basically need a better alternative to ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1e76ba3f0b17849f2f37e]
<FromGitter> <christopherzimmerman> But even using the getter syntax seemed to have the same performance
<FromGitter> <kinxer> And you think the repeated boolean comparison is the bottleneck?
<FromGitter> <christopherzimmerman> Yes, here is the performance when I manually select the correct route: ⏎ ⏎ ```Contiguous 1.12k (896.55µs) (± 0.69%) 192B/op fastest``` [https://gitter.im/crystal-lang/crystal?at=5dc1e8612a6494729ca45c03]
woodruffw has quit [Quit: And then he took off.]
<FromGitter> <christopherzimmerman> I thought I could set the proc in the init method, but then the function tries to access invalid memory each call so it must be losing its scope
woodruffw has joined #crystal-lang
<FromGitter> <christopherzimmerman> On the bright side, as soon as I get this figured out, most of my operations will be as fast or faster than `numpy`, really loving Crystal's performance
<hightower2> fabulous
<FromGitter> <wontruefree> ok this is my shameless plug http://chicagocrystal.org/events/bbhsjryzpbkb/
<FromGitter> <wontruefree> tomorrow talk on data streams
<FromGitter> <wontruefree> favorite quote "the compiler does not bite"
<hightower3> If crystal version is mentioned in shard.yml, does it serve as a minimum version check, or it's used for some other purpose?
<FromGitter> <Daniel-Worrall> it currently serves as a "last known working on" descriptor, but crenv (a crystal version manager) uses it to choose which crystal to run
<hightower3> Cool, thanks
ht_ has quit [Quit: ht_]
go|dfish has quit [Ping timeout: 250 seconds]
<FromGitter> <bajro17> I wish I can go
<FromGitter> <bajro17> @wontruefree there will be stream?
go|dfish has joined #crystal-lang
<FromGitter> <kinxer> @christopherzimmerman @tenebrousedge This is what I came up with: https://gist.github.com/kinxer/e605abc62b91beba58ebd9c6730f978a. I don't know how accurate my benchmarking is, but it's at least a scaffold that y'all could use to iterate further.
<FromGitter> <kinxer> The macros and modules are just for code reuse within the benchmark.
alexherbo273 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <bajro17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc1fd00e1c5e915083db24f]
<FromGitter> <tenebrousedge> is the second conditional necessary?
<FromGitter> <tenebrousedge> can you do `fieldsArray = fields.is_a?(String) ? fields.split(',') : fields`
<oprypin> tenebrousedge, your code is more verbose even if it's on one line
<FromGitter> <tenebrousedge> so?
<oprypin> i suppose the 2nd conditional is to appease type checking
<FromGitter> <bajro17> just now is problem
<FromGitter> <tenebrousedge> and wouldn't the ternary fix that?
<oprypin> it might
<FromGitter> <bajro17> formfields = fieldsArray.join(&->formfield.%(String))
<FromGitter> <bajro17> this dont work
<FromGitter> <tenebrousedge> what does it do?
<FromGitter> <tenebrousedge> if you want to reuse arguments then you need to use the named parameter syntax
<FromGitter> <tenebrousedge> `%(Array)` is a one-to-one positional expression
<FromGitter> <tenebrousedge> so your join would be `join { |e| str % { foo: e } }`
<hightower3> What's the closest equivalent in Crystal to "Streams" that some languages have, like javascript/nodejs?
<FromGitter> <lbarasti> what behaviour of streams are you thinking of, in particular?
<FromGitter> <ImAHopelessDev_gitlab> @bajro17 November 5, 2019 7:16 AM (https://gitter.im/crystal-lang/crystal?at=5dc1924a10bd4128a1c5232e) ⏎ ⏎ i don't know if they will be streaming it however
<hightower3> lbarasti don't know yet, just started to look into that non-crystal code
<hightower3> ehm where is program name? It's not in $0
<FromGitter> <lbarasti> Streams in NodeJS are very peculiar, I'm afraid
<FromGitter> <lbarasti> are you thinking `__FILE__`?
<FromGitter> <tenebrousedge> see constant summary https://crystal-lang.org/api/0.30.1/toplevel.html
<FromGitter> <wontruefree> @bajro17 there will be a stream it is linked in the invite
<FromGitter> <wontruefree> @bajro17 here is the link https://zoom.us/j/3541015445
<FromGitter> <tenebrousedge> `PROGRAM_NAME = String.new(ARGV_UNSAFE.value) `
<hightower3> thanks!
<hightower3> What's the most elegant way to read content line by line, periodically checking if something new came in?
<hightower3> I have an open File, and am at the end of its current content
<FromGitter> <lbarasti> Are constants hoisted in Crystal? Is that documented somewhere? ⏎ ⏎ ```a = 2 ⏎ N = a ⏎ puts N``` ⏎ ⏎ fails compilation with: `error in line 2 Error: undefined local variable or method 'a' for top-level` [https://gitter.im/crystal-lang/crystal?at=5dc209099825bd6bac334803]
HumanGeek has joined #crystal-lang
<FromGitter> <tenebrousedge> constants are evaluated first, pretty sure
<FromGitter> <watzon> ^
HumanGeek has quit [Remote host closed the connection]
<FromGitter> <watzon> They are
HumanGeek has joined #crystal-lang
<FromGitter> <tenebrousedge> hightower, that kinda sounds like a fiber-y channel-y thing
<FromGitter> <lbarasti> should we add some docs on that? The book does not mention it, but it feels pretty crucial to me: https://crystal-lang.org/reference/syntax_and_semantics/constants.html
<FromGitter> <lbarasti> Thanks @tenebrousedge @watzon for confirming
<FromGitter> <tenebrousedge> it does seem like a good thing to mention
<FromGitter> <watzon> It probably should be specified in the docs what actually constitutes a constant
Human_G33k has quit [Ping timeout: 265 seconds]
<FromGitter> <lbarasti> OK, I'll look into that, maybe just an example will do.
<FromGitter> <ImAHopelessDev_gitlab> is it possible to code in an OOP language and a functional one? how is it possible, let alone the core developers ary and brian both code in haskell
<FromGitter> <ImAHopelessDev_gitlab> what do you need to do, to understand both
<FromGitter> <tenebrousedge> functional languages are rarely pure, and any language that has first-class functions should be able to use all of the other functional constructs. So in theory, most programmers are using both at the same time