sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<faustinoaq> Hi, How does `[1,2,4,5].select(&.even?)` work? ⏎ ⏎ I know that `[1,2,4,5]` is an array, also that `select` and `even?` are methods but... ⏎ ⏎ `select(&.even?)` What I'm doing here, is `&` any kind of block of something? [https://gitter.im/crystal-lang/crystal?at=59b34ea84e50cfde271cae55]
<FromGitter>
<ezrast> It's just shorthand for `select {|obj| obj.even?}`
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<faustinoaq> @ezrast Oh, is a bit confusing, so `select(&.even?)` is passing an block as argument in a shorter way.
<FromGitter>
<opensas> hi everyone, I'm trying to format a json string, I saw the JSON::PrettyWriter class but couldn't figure how to use it, can someone provide and example? some simple thing like ```puts JSON::PrettyWriter.new(%({"name": "John", "age": 23}), " ")```
<FromGitter>
<bararchy> JSON.parse()
<FromGitter>
<bararchy> Oh , you want to format
<FromGitter>
<opensas> right!
<FromGitter>
<bararchy> How about parse.pretty_print
<FromGitter>
<opensas> didn't know about it
<FromGitter>
<bararchy> Do we have .to_json on Hash ?
<FromGitter>
<opensas> Now anybody knows how to print to LF in the console??? this is what I get when I execute on the bash console ⏎ ⏎ ```$ crystal rand.cr "{\"name\":\"John\",\"age\":23,\"arr\":[1,2,3]}"``` [https://gitter.im/crystal-lang/crystal?at=59b3988aee5c9a4c5f4c0a59]
A124 has joined #crystal-lang
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<oprypin>
?
rohitpaulk has joined #crystal-lang
<FromGitter>
<kyku> Hi, is there some IDE / editor for Crystal which supports navigating around code and finding symbol usage?
<FromGitter>
<Qwerp-Derp> If I go to `Bar` and right-click, and select "Peek definition", it should bring me to where `Bar` is
<FromGitter>
<kyku> @faustinoaq : I'm gonna give it a try, thanks for the suggestion
<FromGitter>
<Qwerp-Derp> Is anyone willing to clean up my Crystal code? :P
<FromGitter>
<Qwerp-Derp> I'm guessing no, but it's worth a shot
<FromGitter>
<sdogruyol> 👍
ShalokShalom_ has joined #crystal-lang
<FromGitter>
<Qwerp-Derp> @sdogruyol Is that a yes to my request thing?
<FromGitter>
<sdogruyol> unfortunately nope, I'd like to help but don't have the time :/
<FromGitter>
<sdogruyol> I liked the idea though
<FromGitter>
<sdogruyol> :D
ShalokShalom has quit [Ping timeout: 252 seconds]
<FromGitter>
<Qwerp-Derp> Oh :P
ShalokShalom_ is now known as ShalokShalom
<FromGitter>
<kyku> @faustinoaq : is your VSCode plugin supposed to work out of the box? Installed it but seem to only get syntax highlighting
<FromGitter>
<faustinoaq> > Can you add support for finding the definition of a function/class/module/etc., like with other language plugins in VSCode? ⏎ ⏎ @Qwerp-Derp Yeah, I want too, but I'm currently limited to methods/macros because `crystal tool implementation` && `crystal tool expand` command [0] ⏎ ⏎ [0] - https://crystal-lang.org/2015/09/05/tools.html ... [https://gitter.im/c
<FromGitter>
<faustinoaq> > is your VSCode plugin supposed to work out of the box? Installed it but seem to only get syntax highlighting ⏎ ⏎ @kyku The VScode plugin is still in development, so I disabled some unstable features by default. ⏎ ⏎ Features enabled by default: ... [https://gitter.im/crystal-lang/crystal?at=59b3c53e4e50cfde271e2e89]
<FromGitter>
<krypton97> crystal-lib seems to have include issues with llvm-clang@4 ..
<FromGitter>
<Qwerp-Derp> @faustinoaq Is there a way to somehow call shell commands using TypeScript to get the output of `crystal tool`?
<FromGitter>
<Qwerp-Derp> It's a hacky method, but if it works it works
<FromGitter>
<l1meon> Nvm, instead of amber_cmd, build from amber source :)
<FromGitter>
<coderhs> Hi there, where can I find high quality image of crystal. Would like to print some stickers for our an upcoming meetup. Where we are talking about crystal. https://www.meetup.com/kerala-ruby/events/242706539/
<RX14>
pro tip: when your implementation doesn;t pass the specs, just change the specs!
<Rinkana>
Thanks @l1meon . But my example was a very basic version of the issue. In the true issue the `call_foo` function would be in an external lib. So i cant just override it
<Rinkana>
@RX14 Pro-pro tip: just xit the specs that fail
<l1meon>
Rinkana, why not? In ruby you just implement the same namespace for class and methods so you can override them. Or this is not a crystal lib?
<Rinkana>
Yeah true, but i don't want to introduce such patches this soon into my codebase. Especially when the example oprypin gave works too and has no performance impact
<l1meon>
Oh, ok.
<RX14>
l1meon, thats a terrible way to fix it
<l1meon>
RX14, hacks are hacks :)
<RX14>
yes but if foo = @foo is literally shorter and easier
<RX14>
1) it's at the callsite so you dont have to move to a seperate area of the file to monkeypatch
<RX14>
2) it's 2 lines instead of 3
<RX14>
and most of all
<RX14>
it's the correct way to do it in terms of encapsulation
<RX14>
overriding functions to silently ignore nils is just crazy and wrong. It breaks the expectations of every other caller, and can easilly mask errors
<l1meon>
true, maybe I have this in mind cause of the rails ecosystem and gems..
<Rinkana>
Oh tell me some, all those class_eval monkypatches xD
ShalokShalom has quit [Read error: Connection reset by peer]
<l1meon>
yeah, and that's why I'm looking to change language and framework. And how cool was when I found about crystal this year :)
<l1meon>
Wondering if crystal gonna have some breaking changes in syntax or other stuff, till 1.0.
ShalokShalom has joined #crystal-lang
<Rinkana>
Probably
<l1meon>
I'm thinking how hard will be to port to 1.0 if I build with current version for production.
<RX14>
typically the breaking changes aren't too big of a deal if you keep up to date with the versions
<RX14>
its usually a few minor things each version
<RX14>
it does add up though
hightower3 has quit [Remote host closed the connection]
<Rinkana>
yeah true, but mostly some simple style semantics. It's quite simple to port if you look at the changelog
<l1meon>
Ok, thank you. Guess I'll start a project. :) But first, I should better understand the differences between array/tuple, and are the differences cost heavy? in terms of memory/cpu?
<l1meon>
As I'm looking at the docs, I think I'll be using tuples most of the time.
<Papierkorb>
No
<Papierkorb>
Tuples are /not/ arrays. They're structures
<Papierkorb>
They just happen to allow you to iterate over all of its members.
<Papierkorb>
If you have a dynamic list of some kind (Which is the norm), use array.
<Papierkorb>
You're forced to.
<l1meon>
Are some Best Practices anywhere?
<FromGitter>
<faustinoaq> Papierkorb when should I use `StaticArray`?
<Papierkorb>
Tuples are mainly to 1) splat them (you can't splat an array!) 2) use as cheap replacement for a enumerable structure known at compile-time
chamar has quit [Read error: Connection reset by peer]
<RX14>
it's unlikely to be useful outside low-level code
<Papierkorb>
l1meon: Consider this: You have a method which calculates a value from a list: `def calc(list); list.sum; end`. This method is valid Ruby and Crystal. Now, you want to allow a user to (indirectly) supply a list - You use an array for this (Think, REST APIs). But at another point in your program, you want to call this function with a known length of elements. You *can* use both here: `calc({ 1, 2, 3 })` is perfectly valid, as would be an
<FromGitter>
<faustinoaq> Ok 😅
<Papierkorb>
array. What's the difference now? A tuple is a struct, hence it doesn't bother the GC at all, they're "free". So the last example won't allocate any additional memory for the call. If you use an array there, it'll allocate memory. Do note that this comes down to style, this should not be done just because "muh performance"
<Papierkorb>
What RX14 said. Too easy to shoot yourself in your foot if you're not careful.
<RX14>
if you need staticarray, you already know you need staticarray without asking IRC lol
<Papierkorb>
If you're not careful, misuse of StaticArray could end up opening the path for a security exploit in your program.
<FromGitter>
<faustinoaq> lol
<Papierkorb>
Ever heard of buffer under-/overflows? Much harder to do with Arrays, impossible (?) if you just use them normally.
<Papierkorb>
(Don't wanna open the can of worms of stack based exploitation now lul)
chamar has joined #crystal-lang
<chamar>
Hello folks, it's Saturday learning so I thought I would have a look at Crystal. Which VS Code extension is the most up to date / useful? (I see there's 3 of them....)
<FromGitter>
<faustinoaq> > is there any good tutorial around just to get the feels of it? ⏎ ⏎ Yeah, check these videos 👉 https://www.dailydrip.com/topics/crystal
<FromGitter>
<timkendall> I've tried uninstalling/reinstalling Xcode as well
<Yxhuvud>
can't you just install it through brew?
<FromGitter>
<timkendall> thats what I tried - and this is where I ended up lol
<FromGitter>
<faustinoaq> lol
<FromGitter>
<faustinoaq> @timkendall I think you error is pretty strange, let me figure out what is happening here :)
<FromGitter>
<timkendall> Alright thanks man, I appreciate it!
Rinkana has quit [Ping timeout: 260 seconds]
<FromGitter>
<faustinoaq> @timkendall I can't reproduce your problem, Can you try to install clang and compile a simple program? 👇 ⏎ ⏎ ```int main() { return 0; }``` ⏎ ⏎ Seems that your linker is doing something wrong 😟 ... [https://gitter.im/crystal-lang/crystal?at=59b4435ec101bc4e3aa928cc]
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<timkendall> Yeah i figured it was something with my linker 😟
<FromGitter>
<timkendall> clang compiles that simple program fine :/ Thanks for looking into it, obv. not an issue with OSX, just my config for that specific computer. Thanks again!
<FromGitter>
<faustinoaq> 👍 I hope you solve your problem and stay tuned, maybe someone can help in something.
<FromGitter>
<krypton97> I've issues as well with clang trying to generate libvips bindings, but still can build cr apps
<FromGitter>
<timkendall> 👍
weston has joined #crystal-lang
weston has quit [Ping timeout: 240 seconds]
Groogy has joined #crystal-lang
mounibec has joined #crystal-lang
<FromGitter>
<sdogruyol> llvm 5.0 is still not in AUR
<FromGitter>
<sdogruyol> or am i missing it?
<crystal-gh>
[crystal] mverzilli closed pull request #4774: Add support for max + min intrinsics (master...add-math-operations) https://git.io/v7RNn
mounibec has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<FromGitter>
<wwselleck> hey @picatz, if you make some issues in argz i'd be happy to give a go at them. Trying to learn crystal and figure that'd be a good way since I could get some feedback and start small..
mounibec has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
mounibec has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mounibec has joined #crystal-lang
mounibec has quit [Client Quit]
weston has quit [Ping timeout: 240 seconds]
weston has joined #crystal-lang
cptaffe has joined #crystal-lang
<FromGitter>
<crisward> @sdogruyol If you build crystal with llvm 5.0, but sure to share your findings. Especially if it doubles compile speed 😉