Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 20 20:01
    beta-ziliani milestoned #12033
  • May 20 19:13
    beta-ziliani milestoned #12040
  • May 20 18:57
    beta-ziliani milestoned #11984
  • May 20 18:50
    beta-ziliani review_requested #11972
  • May 18 13:16
    hugopl closed #12062
  • May 17 20:20
    Blacksmoke16 synchronize #12044
  • May 17 18:19
    straight-shoota edited #11947
  • May 17 18:19
    straight-shoota milestoned #11947
  • May 17 18:18
    straight-shoota closed #11971
  • May 17 18:18
    straight-shoota closed #11970
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil labeled #12063
  • May 17 17:21
    HertzDevil opened #12063
  • May 17 16:29
    HertzDevil labeled #12062
  • May 17 13:50
    hugopl opened #12062
  • May 17 13:50
    hugopl labeled #12062
  • May 16 19:05
    lbguilherme synchronize #11947
  • May 16 17:29
    straight-shoota milestoned #11971
  • May 16 17:15
    straight-shoota closed #12038
George Dietrich
@Blacksmoke16
i noticed i had acc + i instead of acc + 1, so are all you wanting to do is count the number of time 3 is in the array?
Alex Kampa
@alex-kampa
counting elements in an array that match a certain regex
at this stage just playing around with various ways to achieve that
George Dietrich
@Blacksmoke16
puts [1, 2, 3, 4, 5].count { |i| i.to_s.matches? /3/ }
or in this specific case puts [1, 2, 3, 4, 5].count 3
Alex Kampa
@alex-kampa
thanks, the ".matches?" looks good, short and idiomatic. I know, RTFD :-)
Thanks @Blacksmoke16
From IRC (bridge bot)
@FromIRC
<mfiano> Is there a way I can run ameba automatically when I "run" or "spec"?
George Dietrich
@Blacksmoke16
setup a Makefile
From IRC (bridge bot)
@FromIRC
<mfiano> Fair enough
George Dietrich
@Blacksmoke16
dont think youd want to run it every time you go to run the program tho
From IRC (bridge bot)
@FromIRC
<mfiano> Probably whenever I spec though
George Dietrich
@Blacksmoke16
yea
Jason Waldrip
@jwaldrip
alright, solved that one... next Q
how is is possible to call .from_json on an abstract class and have it resolve to one of its decendants?
From IRC (bridge bot)
@FromIRC
<mfiano> Ah cool, no Makefile required
George Dietrich
@Blacksmoke16
crystal spec && ./bin/ameba?
From IRC (bridge bot)
@FromIRC
<mfiano> on save, vim-crystal seems to annotate the margin and with error icons, and when cursor is on one of those lines, message in status bar
George Dietrich
@Blacksmoke16
ah nice, i know sublime runs the formatter on save as wel, is super nice
From IRC (bridge bot)
@FromIRC
<mfiano> Yeah vim-crystal seems to run the formatter (optionally [disabled by default for some reason]), and ameba if available, though no mention of that or switch for it
From IRC (bridge bot)
@FromIRC
<mfiano> Day 1 actually getting the tooling set up and writing a small amount of code, and I must say, Crystal was easier to get comfortable with than most of the few dozen or so languages I've tried.
George Dietrich
@Blacksmoke16
:thumbsup:
From IRC (bridge bot)
@FromIRC
<mfiano> development_dependencies are included when not building with --release, right, or is there some other criteria that classifies what "development" means?
George Dietrich
@Blacksmoke16
they're dependencies not used in the final build of the code
i.e. ameba, and testing stuff
From IRC (bridge bot)
@FromIRC
<mfiano> Right, I'm looking at debug.cr right now...they say you can call Debug.enabled = true if you don't want to set an env var, so I'm wondering if I can check some flag as to not call that in release builds
George Dietrich
@Blacksmoke16
{% unless flag? :release %}
  Debug.enabled = true
{% end %}
would be true whenever its built without --release
From IRC (bridge bot)
@FromIRC
<mfiano> You mean the inverse ;⁠)
<mfiano> But, thanks
George Dietrich
@Blacksmoke16
i mean Debug.enabled would be true w/o --release
From IRC (bridge bot)
@FromIRC
<mfiano> Oh yes you're right, I read your description wrong.
<mfiano> It might be about time for bed :⁠/
George Dietrich
@Blacksmoke16
but to answer your earlier question doing like shards build --release would also technically install dev dependencies, but is likely you're not requiring those in your main code anyway.
would want to use --production or --without-development, can do shards --help for more info
From IRC (bridge bot)
@FromIRC
<mfiano> Where is a good place to put such meta-code as the above?
George Dietrich
@Blacksmoke16
would need to go in your main entrypoint file, or some other file that requires it
oh i have an idea
have a debug.cr file that you put this stuff in
From IRC (bridge bot)
@FromIRC
<mfiano> Does it matter that it's before the main entry point's "require"s?
George Dietrich
@Blacksmoke16
then you can add a {% skip_file if flag?(:release) %} so that the code isn't processed in release mode
From IRC (bridge bot)
@FromIRC
<mfiano> Oh hmm...and where would that macro form go?
George Dietrich
@Blacksmoke16
first line of debug.cr
From IRC (bridge bot)
@FromIRC
<mfiano> Aha!
From IRC (bridge bot)
@FromIRC
<mfiano> I like that better. It probably means I have to explicitly require debug.cr before other requires for this to work properly, rather than an arbitrary *...or I could be wrong
George Dietrich
@Blacksmoke16
i would advise against using like require "./**"
From IRC (bridge bot)
@FromIRC
<mfiano> Yeah I would too
<mfiano> Though I must be doing something wrong here.