RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
_whitelogger has joined #crystal-lang
sp3ncer has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <iambudi> is possible to call class a propery by string, for example i have many class property name but i want to get only few. Something like : ⏎ ```[“name”,”age”].each {|v| puts @v }```
<FromGitter> <iambudi> @v refer to instance variable
<FromGitter> <Blacksmoke16> would have to use a macro
<FromGitter> <iambudi> yes solved using macro, i thougt there were another solution
<FromGitter> <Blacksmoke16> not by default no, would have to make something on your own
thews has quit [Ping timeout: 240 seconds]
Renich has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> what gives? https://carc.in/#/r/5mdn shouldn't this fall under number 2?
<FromGitter> <Blacksmoke16> prob because `Session` isnt defined?
<FromGitter> <dscottboggs_gitlab> oh, sorry
<FromGitter> <dscottboggs_gitlab> yeah that's I think, it's not picking up that Session is defined, not a very helpful error haha
<FromGitter> <iambudi> how to add to an array inside hash? ⏎ ```hash[“array”] = [“one”, “two”]``` ⏎ ```hash[“array”] << “three”``` seems does not work
<FromGitter> <Blacksmoke16> whats the error?
<FromGitter> <Blacksmoke16> https://carc.in/#/r/5me2
<FromGitter> <dscottboggs_gitlab> your quotes are weird @iambudi
<FromGitter> <Blacksmoke16> that too
<FromGitter> <iambudi> ignore the quote ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfa15f6a6e00567431e25ab]
<FromGitter> <iambudi> i correctly typed in icr
<FromGitter> <Blacksmoke16> not sure what *that* error is saying, but the issue you're prob having is defining the type of the has as `String | Array(String)`
<FromGitter> <Blacksmoke16> there is no `<<` method for `String` so you'll have to check the type of what the hash is before adding to it
<FromGitter> <iambudi> hash.class or typeof(hash) returns Hash(String, Array(String) | String)
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5mec
<FromGitter> <Blacksmoke16> but really you'd be better off with objects
<FromGitter> <Blacksmoke16> then you could get better type safety
<FromGitter> <dscottboggs_gitlab> without raising an exception: https://carc.in/#/r/5mee
<FromGitter> <iambudi> kind of wierd, it works in the online playground but not in my local
<FromGitter> <Blacksmoke16> check character encoding of your file
<FromGitter> <Blacksmoke16> might not be UTF-8, based on your quotes
<FromGitter> <iambudi> nope i can confirm using your code .as(Array(String) works on my local but not work without it
<FromGitter> <Blacksmoke16> well yea, without that there is no << method for String so it would fail
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <iambudi> thanks
<FromGitter> <iambudi> > without raising an exception: https://carc.in/#/r/5mee ⏎ ⏎ I did not know if crystal can do inline assignment in if condition
sp3ncer has quit [Read error: Connection reset by peer]
sp3ncer has joined #crystal-lang
Renich has left #crystal-lang [#crystal-lang]
Renich has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> > inline assignment in if condition ⏎ ⏎ so the interesting thing is that this just comes from the fact that every statement returns a value implicitly. The `=` assignments return the value assigned, and so you can do stuff on the returned value of the assignment
Groogy has quit [Read error: Connection reset by peer]
_whitelogger has joined #crystal-lang
Renich has quit [Ping timeout: 240 seconds]
Renich has joined #crystal-lang
Renich has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
sp3ncer has quit [Quit: Textual IRC Client: www.textualapp.com]
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
<FromGitter> <Qard> Hey, I'm working on an API that needs to be able to take a proc with whatever arbitrary parameters and call it using items in an array as the arguments. Is there some way to make that work? I'm having trouble figuring out if there's a way to work within the type system to support that generically. I tried doing `Tuple.from(...)` on the array to work with the spread feature, but that expects type information to be
<FromGitter> ... given explicitly. Any ideas?
Groogy has joined #crystal-lang
<FromGitter> <r00ster91> does somebody know what the first line in a `shard.lock` stand for? ⏎ "version: 1.0"
<FromGitter> <bararchy> @Qard Maybe let us know what is the incoming data structure and what is the outgoing one
<FromGitter> <bararchy> As in, show me what the data incoming looks like and how you want it out
ua has joined #crystal-lang
ua_ has quit [Ping timeout: 240 seconds]
thews has joined #crystal-lang
Groogy has quit [Quit: WeeChat 2.3]
Groogy has joined #crystal-lang
<FromGitter> <Val> @veelenga : could *codacy-ameba* be used without *docker* , more like *ameba* does ?
<FromGitter> <Val> I see it's a starting project, but I just wanted to know if it's planed =)
<FromGitter> <bararchy> So, I know some people around wanted an HTTP::Crawler => https://github.com/NeuraLegion/crawler
<FromGitter> <bararchy> It's not the most amazing code ever, but it uses selenium and other nice tricks to gather as much forms and urls as possible
<FromGitter> <bararchy> it works really nice with dynamic content etc..
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <j8r> @bararchy great :) Oh, you use Clicr :o
<FromGitter> <bararchy> yeha :) wanted to try it out
<FromGitter> <j8r> is it working fine, no issues?
<FromGitter> <j8r> one thing would maybe having the help commands aligned, but that's a minor
<FromGitter> <bararchy> @j8r also it breaks on `--help` :)
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfab295b74b755b5eded5f1]
<FromGitter> <bararchy> but it works really nice, I like how json like it feels, but I would love to have `--target http://www.com` instead of `target=https:....etc..`
<FromGitter> <j8r> @bararchy it doesn't break, look at https://github.com/j8r/clicr#error-handling
<FromGitter> <j8r> I really need to find a way to align help commands without having to manually add `\t` :/
gangstacat has joined #crystal-lang
<FromGitter> <Blacksmoke16> figure out longest word, add 2 spaces, then add `longest world + 2 - length of other words`
<FromGitter> <j8r> hum so I need to have 2 pass operations
<FromGitter> <bararchy> @j8r .max_by .size ?
<FromGitter> <j8r> the tricky thing is this is only macros, but it might be possible with a macro variable
<FromGitter> <jamesreckon> I have come up a new idea about getting Crystal demo in one place to encourage newbies and experience developers to try any Crystal code in repo without friction or having to search everywhere. Hence, I like to encourage Crystal folks to contribute your code demo to showcase any features which can be related to your or other author’s shards: ⏎ ⏎ https://github.c
<FromGitter> ... om/jamesreckon/Crystal-Code-Showcase-2018
<FromGitter> <dscottboggs_gitlab> > does somebody know what the first line in a `shard.lock` stand for? ⏎ ⏎ That's the version of your project, so that shards can use semver to manage dependencies if other projects use yours as a dependency
<FromGitter> <dscottboggs_gitlab> @r00ster91
<FromGitter> <dscottboggs_gitlab> I'm trying to test a websocket connection, does anyone know how to do that? https://carc.in/#/r/5mh0
<FromGitter> <veelenga> @Val no, Codacy requires docker for integration https://support.codacy.com/hc/en-us/articles/207994725-Tool-Developer-Guide
<FromGitter> <veelenga> well, this is just an app that implements integration with codacy. Once i finish it/submit for review and codacy accepts it, you will be able just to use ameba via codacy UI.
<FromGitter> <Val> Ok my bad, it's an analysis engine.
<FromGitter> <Val> I'll try it =)
Renich has joined #crystal-lang
<FromGitter> <vladfaust> UUIDs docs are overwritten by `crystal/src/uuid/json.cr`: https://crystal-lang.org/api/0.27.0/UUID.html. I guess it's a common issue for monkey-patched objects. cc @RX14
<RX14> yeah
<RX14> thats just wrong
<FromGitter> <drum445> @Blacksmoke16 @j8r thanks again guys for the nginx advice, was much nicer to setup than apache and so far it's working like a charm with a few go/crystal apps :)
<livcd> when do you guys see windows support being released ?
sp3ncer has joined #crystal-lang
<FromGitter> <Blacksmoke16> np
sp3ncer has quit [Read error: Connection reset by peer]
sp3ncer has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> @livcd check out issue #5430
akaiiro has joined #crystal-lang
Groogy has quit [Quit: WeeChat 2.3]
sp3ncer has quit [Read error: Connection reset by peer]
<FromGitter> <greenbigfrog> I've got a class which is more or less just a JSON.mapping ⏎ I'd like to access the data via a `String` ⏎ More or less like rubys `Object#send`, except I only want to call a getter instead of an actual function ⏎ ⏎ Is this possible? [https://gitter.im/crystal-lang/crystal?at=5bfb1383cfa682348d835485]
<FromGitter> <dscottboggs_gitlab> I'm not familiar with Ruby, what does `Object#send` do?
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ at least to my understanding [https://gitter.im/crystal-lang/crystal?at=5bfb142cb6c070105288e170]
<FromGitter> <dscottboggs_gitlab> oh! crystal doesn't have metaprogramming
<FromGitter> <dscottboggs_gitlab> it does macros instead.
<FromGitter> <greenbigfrog> I know
<FromGitter> <dscottboggs_gitlab> is tehre any reason you don't want to use a Hash?
<FromGitter> <greenbigfrog> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfb14a9662131389419f644]
<FromGitter> <greenbigfrog> mind ellaborating?
<FromGitter> <j8r> duck typing?
<FromGitter> <dscottboggs_gitlab> @greenbigfrog you're right, that would be nice to be able to do and I don't know if there is a way to do it in crystal
<FromGitter> <j8r> this can't be done with crystal
<FromGitter> <dscottboggs_gitlab> like if you could access data via `a.__attr__["data"]` or something but I think that is not possible due to being compiled
<FromGitter> <j8r> crystal is statically typed, everything has to be known at compile time
<FromGitter> <j8r> you can use case/when to match string and perform and action
<FromGitter> <greenbigfrog> is there no way at all? `SomeData` would be created once and not altered afterwards
<FromGitter> <dscottboggs_gitlab> @greenbigfrog I have an idea just a minute
<FromGitter> <j8r> a string can't be transformed to a method call magically
<FromGitter> <j8r> this is runtime interpretation, and crystal isn't interpreted
<FromGitter> <greenbigfrog> hm. ok
<FromGitter> <j8r> you can use a case/when
sp3ncer has joined #crystal-lang
<FromGitter> <j8r> `when "do_something" then do_something`
<FromGitter> <greenbigfrog> yep. let's see what idea scott has 😏
<FromGitter> <dscottboggs_gitlab> like this https://carc.in/#/r/5mi6
<FromGitter> <dscottboggs_gitlab> same idea as @j8r
<FromGitter> <dscottboggs_gitlab> lol
<FromGitter> <greenbigfrog> oh. lol
<FromGitter> <greenbigfrog> thanks guys
<FromGitter> <j8r> haha, yes exactly :)
<FromGitter> <j8r> @greenbigfrog not you can use a macro to avoid boilerplate
sp3ncer has quit [Client Quit]
<FromGitter> <greenbigfrog> haven't rly ever understood how macros work...
<FromGitter> <dscottboggs_gitlab> @j8r thanks for pointing out `when...then` I had forgotten about that
<FromGitter> <vladfaust> Could this code be dried? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bfb16b4e25cc2740541dc21]
<FromGitter> <j8r> https://carc.in/#/r/5mid
<FromGitter> <j8r> this way you have a list wuth all methods that can be called with send
<FromGitter> <dscottboggs_gitlab> note that the tuple in the `{% for ... %}` statement must be a contant of some sort
<FromGitter> <greenbigfrog> what does `%w(call_a call_b)` mean?
<FromGitter> <greenbigfrog> and where does `el.id` come from?
<FromGitter> <j8r> that's the methods
<FromGitter> <Blacksmoke16> its an alternate to `["call_a", "call_b"]`
<FromGitter> <greenbigfrog> ah. ok
<FromGitter> <greenbigfrog> ```code paste, see link``` ⏎ ⏎ What's wrong about this? [https://gitter.im/crystal-lang/crystal?at=5bfb1937d24f9324d251e1ca]
<FromGitter> <j8r> please read the docs about macros :)
<FromGitter> <j8r> macro variables are special
<FromGitter> <dscottboggs_gitlab> and don't forget to handle the `else` situation well!
<FromGitter> <dscottboggs_gitlab> maybe make it `get?` that could return nil to avoid runtime exceptions
moei has quit [Quit: Leaving...]
sp3ncer has joined #crystal-lang
akaiiro has quit [Ping timeout: 245 seconds]
Renich has quit [Quit: Renich]