ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.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> <Blacksmoke16> made it auto add the `@` and added suggestions from @bcardiff
<FromGitter> <Blacksmoke16> will publish tomorrow unless i find/think of something else
alex`` has quit [Ping timeout: 258 seconds]
teardown has joined #crystal-lang
go|dfish has quit [Ping timeout: 276 seconds]
Raimondi has quit [Quit: WeeChat 2.5: ¡Chau!]
chemist69 has quit [Ping timeout: 264 seconds]
chemist69 has joined #crystal-lang
sagax has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <sam0x17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d675dcfdbf5ae2d42e289b6]
<FromGitter> <sam0x17> I tried `next next` xD but that doesn't work -- don't really want to have to do the boolean trick if I can avoid it
<FromGitter> <sam0x17> and I can't do `return` here we aren't in a method
absolutejam has joined #crystal-lang
<FromGitter> <dmitryrck> I think what you need is `return`: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ the output of this is `something one ends here`, the `puts` of `something2` is never reached [https://gitter.im/crystal-lang/crystal?at=5d6765983770ed0cbda91b8c]
<FromGitter> <dmitryrck> cc @sam0x17
<FromGitter> <dmitryrck> oh, you mean a block? sorry, I thought it was a method :P
<FromGitter> <absolutejam_gitlab> @sam0x17 `break if foo`?
<FromGitter> <dmitryrck> yeah, I cannot think of anything without a condition: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ output is just *start* and *end* ... [https://gitter.im/crystal-lang/crystal?at=5d6768984b1189084e82a434]
<FromGitter> <absolutejam_gitlab> you can break with a value
<FromGitter> <dmitryrck> `break` does not work I just tested
<FromGitter> <absolutejam_gitlab> it doesn't?
<FromGitter> <absolutejam_gitlab> maybe change it to a `while`
<FromGitter> <absolutejam_gitlab> or just a `loop`
<FromGitter> <absolutejam_gitlab> instead of each
<FromGitter> <dmitryrck> oh, `break` breaks the loop not the block call
<FromGitter> <absolutejam_gitlab> yeah, you can break with a value
<FromGitter> <absolutejam_gitlab> and then return that
<FromGitter> <absolutejam_gitlab> or assign to a variable
<FromGitter> <dmitryrck> I think he wants not to reach ⏎ `# more code...` if something is false inside that `each`
<FromGitter> <absolutejam_gitlab> I'm just spitballing here as I don't really know what you wanna do it's too early haha
<FromGitter> <dmitryrck> it is not too late, 5pm here 😂😂😂
<FromGitter> <absolutejam_gitlab> 7:00am here
<FromGitter> <absolutejam_gitlab> Been up since 5:30
<FromGitter> <renich_gitlab> Good time_of_day
<FromGitter> <renich_gitlab> https://play.crystal-lang.org/#/r/7gt6 ⏎ ⏎ I need that string to be modified by the upcase and downcase statements. How do I do that?
<FromGitter> <renich_gitlab> I already tried: `my_string[i] = c.upcase` and stuff. Doesn't work like that.
<FromGitter> <renich_gitlab> Or maybe, something like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d676fa7c8228962ace2834a]
<FromGitter> <renich_gitlab> Also, tried using `.upcase!`
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 245 seconds]
absolutejam has quit [Ping timeout: 268 seconds]
devil_tux has joined #crystal-lang
<FromGitter> <watzon> @sam0x17 I'm pretty sure the boolean method is the only way to do what you want
<FromGitter> <galvertez> is it just me, or is the return type incorrect for `IO::Buffered#peek` ? ⏎ https://github.com/crystal-lang/crystal/blob/master/src/io/buffered.cr#L98-L109 ⏎ ⏎ i don't see how it can ever be anything other than `Bytes` [https://gitter.im/crystal-lang/crystal?at=5d6773a8a498b67237b516e6]
<FromGitter> <galvertez> or am i just not seeing the whole picture here??
<FromGitter> <watzon> Hmm you might be right. Maybe it use to potentially return a nil but then the method logic got changed and someone forgot to change the return type
<FromGitter> <watzon> Yeah you're definitely right as far as I can tell @galvertez. Maybe open an issue about it?
<FromGitter> <galvertez> ya that's basically what i was thinking
<FromGitter> <galvertez> yep will do 👍
<FromGitter> <galvertez> i haven't looked actually - i might just PR it if i can figure out the proper procedure for compiling/testing etc
<FromGitter> <galvertez> save the maintainers the headache for something this trivial lol
lkw has quit [Quit: ZNC 1.7.3 - https://znc.in]
<FromGitter> <renich_gitlab> If anyone has time, I would appreciate any style corrections to this: https://play.crystal-lang.org/#/r/7gt8. It's my solution in code wars to this kata: https://www.codewars.com/kata/playing-with-passphrases/train/crystal. I know it sucks, but I'm trying to make myself a better crystal programmer. Thanks in advance! ;D
* FromGitter * renich_gitlab goes to sleep since it's 02:12 here
absolutejam has joined #crystal-lang
alex`` has quit [Ping timeout: 245 seconds]
devil_tux has quit [Ping timeout: 246 seconds]
hightower2 has joined #crystal-lang
ua has quit [Excess Flood]
ua has joined #crystal-lang
devil_tux has joined #crystal-lang
absolutejam has quit [Ping timeout: 245 seconds]
<FromGitter> <kimvex> Hi, I have a question. When you run a file in development mode using the “run” command example: crystal run hello_world.cr this saves the file in cache so that the next time you run it, take it from the cache?
<FromGitter> <kimvex> I ask because I had a problem to be testing and making changes to an endpoint in kemal, and every time I made a change, it was not reflected, if it was not still answers from the previous code that had that endpoint, until I deleted the code and added changes to those same lines and kept responding with the old code information
<FromGitter> <watzon> @kimvex I've had the same problem before. Yes, crystal run builds the file and caches it, I believe on Linux the Crystal cache is stored at ~/.cache/crystal but I could be wrong. Usually whenever I have a problem that I feel might be cache related I delete that folder.
<FromGitter> <kimvex> The problem stopped appearing when I started using the "--release" flag next to the "run" command. crystal run hello_world.cr —release
<FromGitter> <kimvex> Chris Watson Sometimes that causes me problems when I delete that folder, which is why I try to avoid deleting it, but I will try again deleting it to see what happens
<FromGitter> <watzon> @renich_gitlab the only thing I can really recommend is to look into `String.build` and use that rather than concatenating. It's much faster. Other than that things look pretty good.
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 245 seconds]
go|dfish has joined #crystal-lang
devil_tux has quit [Ping timeout: 244 seconds]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 246 seconds]
devil_tux has joined #crystal-lang
absolutejam has joined #crystal-lang
DTZUZO has quit [Ping timeout: 258 seconds]
absolutejam has quit [Ping timeout: 246 seconds]
absolutejam has joined #crystal-lang
devil_tux has quit [Ping timeout: 244 seconds]
devil_tux has joined #crystal-lang
DTZUZO has joined #crystal-lang
absolutejam has quit [Ping timeout: 272 seconds]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Is there any way to initialize a class like a literal?
<FromGitter> <absolutejam_gitlab> A la elixir / go struct
<FromGitter> <absolutejam_gitlab> `Foo{bar: "a"} `
<FromGitter> <absolutejam_gitlab> I
<FromGitter> <absolutejam_gitlab> I know I could define each property in the initialize method
<FromGitter> <tenebrousedge> you can do that for `Hash`, right? so yes
<FromGitter> <absolutejam_gitlab> Or do it as a block but I'm thinking of that self contained syntax
<FromGitter> <tenebrousedge> ...hmm, I'm misremembering
<FromGitter> <absolutejam_gitlab> Hash has that kind of literal yeha
<FromGitter> <absolutejam_gitlab> Yeah
<FromGitter> <tenebrousedge> right, but with arrow syntax
<FromGitter> <tenebrousedge> what's wrong with a `Struct` though?
absolutejam has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Nothing, I just want a literal way to initialize a class or struct if possible
<FromGitter> <absolutejam_gitlab> it might not be idiomatic but I want it!
<FromGitter> <absolutejam_gitlab> I could do ⏎ ⏎ ```a = Foo.new ⏎ a.bar = "a"``` [https://gitter.im/crystal-lang/crystal?at=5d67c543e14c193f9d95ee87]
<FromGitter> <absolutejam_gitlab> but it's gross
<FromGitter> <absolutejam_gitlab> I could write a macro that iterates over properties perhaps
<FromGitter> <tenebrousedge> "Hash-like type literal"
<FromGitter> <absolutejam_gitlab> But that is essentially a named type that incorporates a hash, right?
<FromGitter> <absolutejam_gitlab> which is great, but has no key validation
<FromGitter> <tenebrousedge> no, any class with an argless constructor that responds to []
<FromGitter> <absolutejam_gitlab> An Elixir/Golang struct is essentially a hash with specified keys
<FromGitter> <j8r> @absolutejam_gitlab Why you *need* that?
<FromGitter> <absolutejam_gitlab> I don't, I'm just curious if it exists
<FromGitter> <absolutejam_gitlab> so I could write a class that responds to `[]` and assigns each to each property
<FromGitter> <j8r> In Crystal, there is one way `MyObject.new(key1: value1, key2: value2)`
<FromGitter> <j8r> don't get what's wrong
<FromGitter> <absolutejam_gitlab> That requires `initialize` with the parameters though, right?
<FromGitter> <absolutejam_gitlab> Or does that work if you don't supply an `initialize`?
<FromGitter> <j8r> Yes
<FromGitter> <tenebrousedge> @absolutejam_gitlab looks like you would just have to write `[]`, yes
<FromGitter> <absolutejam_gitlab> right
<FromGitter> <j8r> but that's good, you can have private ivars
<FromGitter> <absolutejam_gitlab> I have no issue with the current way, but writing some other languages, I sometimes appreciate being able to create a 'structure hash' instead of a full-fledged ckass
<FromGitter> <absolutejam_gitlab> class*
<FromGitter> <j8r> I know what you are looking for @absolutejam_gitlab , `record`
<FromGitter> <j8r> @absolutejam_gitlab look at https://crystal-lang.org/api/master/toplevel.html#record(name,*properties)-macro
<FromGitter> <absolutejam_gitlab> @j8r that's it
<FromGitter> <absolutejam_gitlab> thanks
<FromGitter> <absolutejam_gitlab> I'm not going to go any ditch all my classes now, but I also think this has its use for simpler cases
<FromGitter> <Blacksmoke16> ofc know its passed by copy
devil_tux has quit [Ping timeout: 245 seconds]
<FromGitter> <absolutejam_gitlab> I was just toying ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d67cf4285a9157cb44454a2]
<FromGitter> <absolutejam_gitlab> Need to play with macros more
<FromGitter> <absolutejam_gitlab> but a record is great
<FromGitter> <absolutejam_gitlab> and yeah @Blacksmoke16 ty
<FromGitter> <Blacksmoke16> i dont think that would work
<FromGitter> <tenebrousedge> you could use a `case`
<FromGitter> <Blacksmoke16> ^
<FromGitter> <tenebrousedge> but records do seem like a good way to go
<FromGitter> <absolutejam_gitlab> Oh yeah, I didn't actually notice it didn't work haha
<FromGitter> <absolutejam_gitlab> jesus christ, observant,.
<FromGitter> <absolutejam_gitlab> looks like it's evaluating to `index` instead of the index value
<FromGitter> <Blacksmoke16> thats not how macros work
<FromGitter> <absolutejam_gitlab> I still think it'd be nice to do what you can do in Nim, and get raw AST access
<FromGitter> <Blacksmoke16> its expanding to like
<FromGitter> <absolutejam_gitlab> Yeah, just tested it
<FromGitter> <Blacksmoke16> ``` def []=(index, value) ⏎ "a" = "apple" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d67d0108deffa6acf9e1a39]
<FromGitter> <j8r> in you example, you would need `{% for ivar in @type.instances_vars %}`
<FromGitter> <absolutejam_gitlab> Metaprogramming really breaks my brain. And I see what you mean, thanks
<FromGitter> <absolutejam_gitlab> I realise this is a useless, contrived example. Just for curiosity really
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7gu9
<FromGitter> <tenebrousedge> that's a lovely little snippet for a mixin
<FromGitter> <j8r> I think the closest is NamedTuple or record, the latter is generally better
<FromGitter> <absolutejam_gitlab> I forgot about named tuples haha
<FromGitter> <absolutejam_gitlab> spoiled for choice
<FromGitter> <j8r> I recommend records anyway, simpler for typing too, and you can add methods
<FromGitter> <absolutejam_gitlab> @Blacksmoke16 very nice
<FromGitter> <absolutejam_gitlab> yeah definitely
<FromGitter> <absolutejam_gitlab> I was already sold, I was just curious
<FromGitter> <absolutejam_gitlab> I assume records just do a similar thing under the hood, just haven't looked at the source
<FromGitter> <j8r> record is fairly simple
<FromGitter> <j8r> is generate getters, that's it
<FromGitter> <Blacksmoke16> also some other stuff
<FromGitter> <Blacksmoke16> like the initializer and the copy with method
<FromGitter> <Blacksmoke16> and clone
<FromGitter> <j8r> of course initialize yes
<FromGitter> <j8r> the others I didn't see
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
absolutejam has quit [Ping timeout: 245 seconds]
absolutejam has joined #crystal-lang
Raimondi has joined #crystal-lang
Yxhuvud has joined #crystal-lang
absolutejam has quit [Ping timeout: 244 seconds]
<FromGitter> <renich_gitlab> @watzon will do. Thank you!
<FromGitter> <andrius> When I run crystal spec, it does not load some depandant files and failing, That's unexpected. Anything wrong? https://share.icloud.com/photos/0QHSmOq8SyWxJ6p0bhOtdMNjw
<FromGitter> <Blacksmoke16> you sure you required them in your spec helper?
<FromGitter> <andrius> yes, root file, but that one has more require directives (I've made screenshot)
<FromGitter> <Blacksmoke16> is it required before the require that uses it?
<FromGitter> <andrius> yes. in my case it is failing in macro
<FromGitter> <andrius> this line is failing
<FromGitter> <andrius> when I run `crystal spec --error-trace spec/ari_spec.cr`
devil_tux has joined #crystal-lang
<FromGitter> <Blacksmoke16> i think you need to do `require "./ari/events/**"`
<FromGitter> <Blacksmoke16> so it'll recursively includes files within other directories
<FromGitter> <Blacksmoke16> er nvm
<FromGitter> <Blacksmoke16> nothing jumps out at me :/
<FromGitter> <andrius> it fails even if I directly include class definition
<FromGitter> <Blacksmoke16> im assuming the app itself works?
<FromGitter> <Blacksmoke16> just not the specs
<FromGitter> <asterite> I get: Error: can't find file './ari/resources/*' relative to '/Users/asterite/Sandbox/asterisk/src/asterisk'
<FromGitter> <asterite> do you have changes in "develop"?
<FromGitter> <asterite> when I remove that require it compiles fine
<FromGitter> <j8r> @Blacksmoke16 that's a bad advice, using `**` yield to errors related to import order
<FromGitter> <j8r> *can yield
Human_G33k has joined #crystal-lang
<FromGitter> <andrius> Resources is empty yet. Thanks, will fix that ;)
HumanGeek has quit [Ping timeout: 246 seconds]
<FromGitter> <absolutejam_gitlab> Q
<FromGitter> <tenebrousedge> A
<FromGitter> <Blacksmoke16> tis done
sorcus has joined #crystal-lang
OvermindDL1 has joined #crystal-lang
<FromGitter> <sam0x17> gotcha, thanks guys
devil_tux has quit [Ping timeout: 258 seconds]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
absolutejam has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> sorry, gitter on my phone is risky business
<FromGitter> <absolutejam_gitlab> and I still can't use the app 😓
<FromGitter> <jeromegn> anybody faced this issue trying to deploy lucky with docker: ⏎ ⏎ ```/bin/sh: script/precompile_tasks: not found```
<FromGitter> <jeromegn> using crystal 1.30.1
<FromGitter> <jeromegn> lucky 0.17
<FromGitter> <jeromegn> I tried setting SKIP_LUCKY_TASK_PRECOMPILATION, but that didn't help (to my surprise)
<FromGitter> <jeromegn> ^ because it just can't find the file, so not that surprising heh
<FromGitter> <Blacksmoke16> first thought is are you sure you're mounting that file into the container?
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
<FromGitter> <jeromegn> well this is during the docker image build process, at that point I've only copied the shard.* files. but I also tried with everything copied before the `shards install` step and got the same error.
<FromGitter> <jeromegn> using this Dockerfile
<FromGitter> <jeromegn> `docker build -t lucky-example --build-arg ENTRY_FILE=src/app.cr .`
<FromGitter> <absolutejam_gitlab> run the step manually
<FromGitter> <absolutejam_gitlab> in a container
<FromGitter> <absolutejam_gitlab> and see what files are created etc.
<FromGitter> <jeromegn> good idea, going to try that
<FromGitter> <absolutejam_gitlab> you should be able to use the existing intermediate image iirc
<FromGitter> <absolutejam_gitlab> so you don't have to run all the previous steps
Raimondi has quit [Ping timeout: 258 seconds]
<FromGitter> <absolutejam_gitlab> `docker image ls -a` to see those images
<FromGitter> <jeromegn> somehow it hasn't even install lucky
<FromGitter> <jeromegn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d6829fded0bf6683aabbd51]
<FromGitter> <jeromegn> doesn't make much sense, hmm.
absolutejam1 has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> what's in your shards.yaml?
<FromGitter> <jeromegn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d682aef2f10da7cb3577508]
<FromGitter> <jeromegn> this is a brand new lucky app created with `lucky init`
absolutejam has quit [Ping timeout: 246 seconds]
<FromGitter> <absolutejam_gitlab> weird because it has `Installing lucky (0.17.0)` in the output
<FromGitter> <jeromegn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d682b83bee75051a41b7218]
<FromGitter> <absolutejam_gitlab> I've noticed a couple of times that the compiler doesn't detect errors in untravelled logic paths
<FromGitter> <absolutejam_gitlab> replicated the same thing in Go and it's caught
<FromGitter> <absolutejam_gitlab> just something I've noticed
<FromGitter> <absolutejam_gitlab> What's that, verbose output?
<FromGitter> <jeromegn> yea
<FromGitter> <jeromegn> that's weird
<FromGitter> <jeromegn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d682cd79fd19e68397dbab6]
<FromGitter> <jeromegn> why would it remove the shard before running the scripts
<FromGitter> <jeromegn> unless I'm not reading that right
<FromGitter> <absolutejam_gitlab> is it sequential or does it use fibers and they're getting out of order?
<FromGitter> <jeromegn> it looks sequential, I'll run it a few more times
devil_tux has joined #crystal-lang
<FromGitter> <jeromegn> sequential as far as I can tell
<FromGitter> <absolutejam_gitlab> yeah, the shards source has no fibers in it
<FromGitter> <jeromegn> I wonder if I'm missing some directory structure
<FromGitter> <jeromegn> it works fine for crystal apps that don't have dependencies with scripts
Raimondi has joined #crystal-lang
MasterdonX has quit [Read error: Connection reset by peer]
MasterdonX has joined #crystal-lang
<FromGitter> <jeromegn> just tried an earlier shards version and it yields the same results
<FromGitter> <jeromegn> at this point I might stop being clever and just use a bigger image
<FromGitter> <tenebrousedge> shaving yaks can be fun, if you have time for it
<FromGitter> <jeromegn> they're very hairy
<FromGitter> <absolutejam_gitlab> I didn't realise that you could reassign a variable to a different type
<FromGitter> <Blacksmoke16> if you dont type the variable, yes
<FromGitter> <absolutejam_gitlab> ah, so if i explicitly type it, then I cant?
<FromGitter> <Blacksmoke16> correct
<FromGitter> <absolutejam_gitlab> makes sense I guess
<FromGitter> <absolutejam_gitlab> makes a lot of sense 👍
<FromGitter> <absolutejam_gitlab> I might start using structs more as a default
<FromGitter> <Blacksmoke16> record ftw
<FromGitter> <watzon> @andrius ideally don't share icloud screenshots, post the actual code to somthing like hastebin or even just try and make a working example of your issue on https://carc.in
<FromGitter> <watzon> It makes it a lot easier to help
<FromGitter> <absolutejam_gitlab> TIL of carc.in, much easier than https://play.crystal-lang.org/#/crystal
<FromGitter> <Blacksmoke16> not when you just type `p` and chrome autocompletes it for you :p
<FromGitter> <jeromegn> @absolutejam_gitlab @Blacksmoke16 update: my issue is fixed with the official crystal docker image :/
devil_tux has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> oh well
Raimondi has quit [Ping timeout: 258 seconds]
absolutejam1 has quit [Ping timeout: 272 seconds]
lkw has joined #crystal-lang
absolutejam1 has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
gangstacat has quit [Quit: Ĝis!]
Yxhuvud has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
Raimondi has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 268 seconds]
DTZUZU has quit [Quit: WeeChat 2.2]
alex`` has quit [Ping timeout: 258 seconds]
<FromGitter> <sam0x17> so I'm about to attempt to make a macro that, when called in a possibly arbitrarily nested block, will (somehow) do the equivalent of calling `next` up the chain of blocks so that all the blocks exit........... what should I call the macro lol?
<FromGitter> <Blacksmoke16> would that even work