Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:47
    straight-shoota closed #12051
  • 13:47
    straight-shoota closed #12050
  • 12:17
    beta-ziliani edited #7318
  • May 15 08:43
    r00ster91 closed #7318
  • May 15 08:17
    r00ster91 closed #7690
  • May 14 17:01
    Blacksmoke16 labeled #11995
  • May 14 13:03
    webhive closed #12055
  • May 14 10:19
    straight-shoota milestoned #12051
  • May 14 10:00
    I3oris edited #12051
  • May 14 08:45
    oprypin review_requested #11977
  • May 13 23:29
    Blacksmoke16 unlabeled #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 opened #12061
  • May 13 20:14
    straight-shoota labeled #12060
  • May 13 20:14
    straight-shoota labeled #12060
  • May 13 20:14
    straight-shoota opened #12060
Ghost
@ghost~55586c4815522ed4b3e08557
Groogy seems broken, or a weird compiler... try on yours?
From IRC (bridge bot)
@FromIRC
<Groogy> or they just wrote wrong result
<Groogy> the stackoverflow shows what I would expect
Ghost
@ghost~55586c4815522ed4b3e08557
weird, I got the same, maybe it's in bits not bytes
From IRC (bridge bot)
@FromIRC
<Groogy> huh you got 8 bits with the example?
Ghost
@ghost~55586c4815522ed4b3e08557
yes
From IRC (bridge bot)
@FromIRC
<Groogy> could also be padding :⁠/
<Groogy> if I do a struct with two ints, I get 4 bytes as result
<Groogy> so pretty sure it is in bytes
<Groogy> at least using clang++
Ghost
@ghost~55586c4815522ed4b3e08557
doc says it's bytes
From IRC (bridge bot)
@FromIRC
<Groogy> yeah and two members of ints, with second returning 4 means it is bytes
<Groogy> so in that example the compiler is adding padding
Ghost
@ghost~55586c4815522ed4b3e08557
ah you may be right
From IRC (bridge bot)
@FromIRC
<Groogy> uuugh now I have to have access to the face->glyph->bitmap
<Groogy> ;_;
<Groogy> make good API pls
<Groogy> think of the poor programmers
<Groogy> eeh I'll tackle this some other day
Ghost
@ghost~55586c4815522ed4b3e08557
useless but fun https://carc.in/#/r/2ru4
(use oneline & multiline block in the same line)
Faustino Aguilar
@faustinoaq
I have a question, ECR templates are inlined and embedded to binary executable when a project is compiled, so Would this approach be faster that reading file system each time like all common web frameworks do?
Ghost
@ghost~55586c4815522ed4b3e08557
yeah totally
the templating file is read & parsed at compile time, where other templating needs to do this at runtime (they'll probably read & parse only once, and keep the parsed template somewhere in memory)
George
@georgeu2000
How do I declare instance variable @abundants?
class Foo
  def bar
    @abundants = ( 1..100 ).select do | i |
        sum_of_divisors_for( i ) > i
     end
It is an array of Int32.
I get Can't infer the type of instance variable '@abundants' of Calculator.
Ghost
@ghost~55586c4815522ed4b3e08557
you need to declare it as @abundants : Array(Int32)
George
@georgeu2000
instance variable '@abundants' of Foo was not initialized in all of the 'initialize' methods, rendering it nilable, so it seems I need to initialize it in the initialize method...
Ghost
@ghost~55586c4815522ed4b3e08557
depends on what you need, if it can be nil, you can declare it as an Array(Int32)? (note the ?, making it nilable), or you can init it in initialize either with a default value (empty array?) or with your code
George
@georgeu2000
Oh, I see. Thanks.
Zafar Ansari
@ansarizafar
I have initiated a class defined in a module. How can access its methods
require "logger"
require "colorize"

module WebWare 

    class Log 

        def initialize
        @log = Logger.new(STDOUT)
        end

        def logme(message, color) 
        @log.info message.colorize(color)
        end

    end

end

WebWare::Log.new
Ghost
@ghost~55586c4815522ed4b3e08557
did you read the documentation? https://crystal-lang.org/docs
you can access those method like any other methods in any classes
as in my_log = WebWare::Log.new; my_log.logme("msg", color)
Zafar Ansari
@ansarizafar
I have read guide/api documentation. I have initiated the calls like this WebWare::Log.new without assigning it to a variable as mentioned in the guide https://crystal-lang.org/docs/syntax_and_semantics/modules.html my question is how can I access methods from a different file
Ghost
@ghost~55586c4815522ed4b3e08557
you just need the module in a separate file, not the last line. In another file, require the file with the module (see https://crystal-lang.org/docs/syntax_and_semantics/requiring_files.html), then you can instantiate your class (save the instance to a variable) and use its methods.
Zafar Ansari
@ansarizafar
Another related question is how can I create singleton object . I don't want to initiate Log class in every file.
Ghost
@ghost~55586c4815522ed4b3e08557
2 ways (maybe more, I don't know): with a constant (intialized before everything), with a class method (initialized on first demand). example: https://carc.in/#/r/2rv5
Zafar Ansari
@ansarizafar
class variable did the job me.
Bar Hofesh
@bararchy
So, i opened a channel for supporting crystal-fann if anyone needs it: https://gitter.im/crystal-fann/Lobby
Serdar Dogruyol - Sedo セド
@sdogruyol
Morning everyone
@bararchy great job with crystal-fann :+1:
From IRC (bridge bot)
@FromIRC
<Groogy> Morning!
unreadable
@unreadable
morning all, just found this awesome git rank
seems that apple beat microsoft x)
Serdar Dogruyol - Sedo セド
@sdogruyol
lol
Crystal beats Scala there