ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
ur5us has joined #crystal-lang
debayer has quit [Read error: Connection reset by peer]
<raz> hmm. that Iterator sample code almost tempts me to take another stab at parallel fetching for `shards`
<FromGitter> <Blacksmoke16> there is an `.of` method
<FromGitter> <Blacksmoke16> not documenting, but i think thats somewhat related to what its used for
<FromGitter> <Blacksmoke16> creating an iterator of an existing obj or block
notzmv has joined #crystal-lang
<raz> i think i've asked this before. is there a way to detect if my code is running under spec?
<FromGitter> <nanobowers> This article ⏎ ⏎ does a dive into crystal arrays (with some comparison to ruby)
<FromGitter> <Daniel-Worrall> Raz you can check if the Spec constant is defined
<raz> ahhh good idea. thanks!
<FromGitter> <Daniel-Worrall> E.g. ⏎ {% skip_file if @top_level.has_constant? "Spec" %}
<FromGitter> <Blacksmoke16> whats the use case?
<FromGitter> <Daniel-Worrall> My use case was specing my runnable socks
<FromGitter> <Daniel-Worrall> AoCs
<FromGitter> <Blacksmoke16> could you define whatever within `spec_helper`?
<FromGitter> <Blacksmoke16> that file is only loaded in spec context
<raz> well i don't want to monkey patch around too much. checking if `Spec` is defined is perfect
<raz> (i feel like i've even done that before but then forgot about it)
notzmv has quit [Ping timeout: 240 seconds]
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
notzmv has joined #crystal-lang
taupiqueur has joined #crystal-lang
debayer9 has joined #crystal-lang
debayer9 has quit [Client Quit]
taupiqueur has quit [Ping timeout: 256 seconds]
<FromGitter> <karan718> Hello ⏎ ⏎ Is it possible to define methods on generic classes. ⏎ For example, Is it possible to define an instance method called 'join' which takes instance of Array(String) as receiver but not instances of Array(T) ⏎ ... []
<FromGitter> <Blacksmoke16> @karan718 i think you have a few options depending on your exact context
<FromGitter> <Blacksmoke16> like I'm assuming you want this method on a custom type that wraps an array?
<FromGitter> <karan718> @Blacksmoke16 ⏎ I would like for all the methods are that are defined for Array(T) to be available on this custom type. ⏎ I tried doing something like ⏎ `class ArrayOfStrings < Array(String) ⏎ ... []
<FromGitter> <Blacksmoke16> i would suggest *not* extending the base array type and instead have a type that wraps the array. like a decorator
<FromGitter> <Blacksmoke16> then you could force it to only accept an `Array(String)`
<FromGitter> <karan718> @Blacksmoke16 can you point me to some documentation or example that uses this pattern
<FromGitter> <Blacksmoke16> ```code paste, see link``` []
<FromGitter> <Blacksmoke16> something like that
<FromGitter> <Blacksmoke16> may need to make it `getter array : Array(String)` as you wouldnt be able to pass it to things restricted to `Array`
<FromGitter> <karan718> I will give this a shot and get back to you. ⏎ How did you become familiar with the concept of `forward_missing_to` ? ⏎ Also, why do recommend against extending the base array type?
<FromGitter> <Blacksmoke16> it's in the API docs
<FromGitter> <karan718> Thanks @Blacksmoke16
<FromGitter> <Blacksmoke16> and i cant find the specific issue (if there is one), but afaik in the past it just causes issues
<FromGitter> <Blacksmoke16> same with any of the built in collection types
taupiqueur has joined #crystal-lang
taupiqueur has quit [Ping timeout: 240 seconds]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Ping timeout: 256 seconds]
notzmv has quit [Ping timeout: 240 seconds]
taupiqueur_ has quit [Remote host closed the connection]
taupiqueur has joined #crystal-lang
notzmv has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter> <> howdy, is there method to iterate over and recurse through a directory? I've found .each and stuff but they dont seem to recurse according to the docs
<FromGitter> <Blacksmoke16> probably want something in
<FromGitter> <Blacksmoke16> `Dir.glob` maybe
taupiqueur has quit [Quit: taupiqueur]
ur5us has quit [Ping timeout: 240 seconds]