Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:10
    HertzDevil synchronize #12785
  • 14:07
    straight-shoota opened #12786
  • 14:07
    straight-shoota labeled #12786
  • 14:07
    straight-shoota labeled #12786
  • 14:00
    HertzDevil synchronize #12785
  • 13:55
    HertzDevil edited #12785
  • 13:54
    HertzDevil ready_for_review #12785
  • 13:54
    HertzDevil synchronize #12785
  • 13:49
    HertzDevil edited #12785
  • 13:35
    HertzDevil converted_to_draft #12785
  • 13:32
    HertzDevil labeled #12785
  • 13:32
    HertzDevil labeled #12785
  • 13:32
    HertzDevil opened #12785
  • 13:05
    HertzDevil converted_to_draft #12784
  • 10:38
    HertzDevil edited #12784
  • 10:37
    HertzDevil labeled #12784
  • 10:37
    HertzDevil labeled #12784
  • 10:37
    HertzDevil opened #12784
  • 00:07
    Blacksmoke16 labeled #12783
  • 00:07
    Blacksmoke16 labeled #12783
Ramakrishnan Vasantha Gopal
@vgramkris
but from string to num i need to check with .to_i32? and then assign
that is what i was trying to understand if there is any reason why for string they did not have .to_i32! while they do have .to_i32 for string
George Dietrich
@Blacksmoke16
still not sure i follow, you deff can do like d : Int32 | Nil = c.to_i32?
because to_i32! represents a wrapping operation on the value if it over/underflows. In the case of a string its to_i32? because you cant wrap a string, and needs to handle the case of the string not being a number. So it'll return nil if either of those happen
Ramakrishnan Vasantha Gopal
@vgramkris
okay this makes sense.. thanks!
George Dietrich
@Blacksmoke16
there is a block version of to_i32 that you can use. Which will use the blocks value in case of under/overflow or its not a valid number
e.g. e : Int32 = c.to_i { 0 }
habit, to_i is the same as to_i32
Ramakrishnan Vasantha Gopal
@vgramkris
sure, this would work as well! thanks @Blacksmoke16
George Dietrich
@Blacksmoke16
np, ofc another solution is to just not go from number to string to number :)
but i assume that was just an example
Ramakrishnan Vasantha Gopal
@vgramkris
:)
baiorett
@baiorett
hi, quick question: how do i split crystal classes to multiple files
George Dietrich
@Blacksmoke16
for what reason?
Daniel Worrall
@Daniel-Worrall
Just define them in multiple files.
You can reopen classes
George Dietrich
@Blacksmoke16
but to answer your question just declare the class and add more stuff to ^
re-declare
Daniel Worrall
@Daniel-Worrall
If you're overwriting methods in the same class, require order matters
baiorett
@baiorett
alright thank you
George Dietrich
@Blacksmoke16
i'd suggest thinking if you really want to do that tho. could just make things more confusing
baiorett
@baiorett
im sorta used to splitting classes because i came to crystal from java
George Dietrich
@Blacksmoke16
Other people might not be. Especially if it's a small type
Depends on the exact use case tho. Not going to really harm anything, but is possible it might mess with overload order
baiorett
@baiorett
Depends on the exact use case tho. i don’t think i’m really going to split each class and make tons of class-files
From IRC (bridge bot)
@FromIRC
<postmodern> how do i link to constants in crystal docs?
<postmodern> also references to class-methods don't seem to be auto-linking.
George Dietrich
@Blacksmoke16
@baiorett good :P
surround the const in back ticks
are you using a . instead of #?
From IRC (bridge bot)
@FromIRC
<postmodern> oh derp. kind of weird to overload markdown syntax like that, but ok
<postmodern> so .foo and #foo should link to the appropriate methods? foo won't, correct?
George Dietrich
@Blacksmoke16
it might if its in the same scope/file
From IRC (bridge bot)
@FromIRC
<postmodern> er yeah, found the example in the reference
From IRC (bridge bot)
@FromIRC
<postmodern> where is the repo for the crystal doc command? i noticed it doesn't add a # link next to constants, to allow permalinking to them.
George Dietrich
@Blacksmoke16
It's in crystal codebase
Can link to constants section but not a specific one ATM
From IRC (bridge bot)
@FromIRC
<postmodern> does crystal docs markdown parser understand tables?
George Dietrich
@Blacksmoke16
I would highly doubt it
But you can try
option b would be using mkdocs crystal extension
From IRC (bridge bot)
@FromIRC
<dostoyevsky2> I use a docker container these days as my dev environment... is there a way I could compile a crystal program for osx from linux/inside a docker container?
George Dietrich
@Blacksmoke16
mac doesn't support static binaries so that might be a bit tricky, however assuming its the same arch and the mac has the libraries installed it should work fine
libraries like ones crystal runtime depends on, i.e. the dynamically linked ones
would be easier to just build on the mac
From IRC (bridge bot)
@FromIRC
<postmodern> so crystal prefers grammatically correct method names, like includes?. What are people's opinions on "indices" vs "indexes"?
From IRC (bridge bot)
@FromIRC
<riza> do what you think is rightd
<riza> a classing example in the rails world is "medium" is the proper singular of "media" but nobody knows that
From IRC (bridge bot)
@FromIRC
<postmodern> do people using write tests for delegateed methods?