BlaXpirit has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
sfcgeorge has joined #crystal-lang
BlaXpirit has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
<jhass>
mmh, same type should be doable
pawnbox has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leafybasil has quit [Read error: Connection reset by peer]
leafybasil has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
trapped has joined #crystal-lang
pawnbox has joined #crystal-lang
BlaXpirit has quit [Quit: Konversation]
Ven has joined #crystal-lang
Netfeed has quit [Quit: WeeChat 1.0.1]
pawnbox has quit [Remote host closed the connection]
Netfeed has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Philpax_ has quit [Ping timeout: 240 seconds]
Ven_ has quit [Ping timeout: 265 seconds]
badeball_ is now known as badeball
pawnbox has quit [Remote host closed the connection]
gamemanj has joined #crystal-lang
bcardiff has joined #crystal-lang
BlaXpirit has joined #crystal-lang
pawnbox has joined #crystal-lang
leafybasil has quit [Read error: Connection reset by peer]
leafybas_ has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
olek_poz has joined #crystal-lang
cyjimmy264 has joined #crystal-lang
pawnbox has joined #crystal-lang
<olek_poz>
Hello guys, is it possible to declare class variable using more advanced object like own class, or Logger? "@age :: Int32" works, but "@logger :: Logger" not. I'd like to be able to assign object A to object B after object B was initialized.
<jhass>
olek_poz: try living without :: for a while, class variables are subject to autovivification and type inference should do the rest
<jhass>
in general you should never need :: unless you interact with external C libraries directly
<olek_poz>
error "was not initialized in all of the 'initialize' methods, rendering it nilable". I'm thinking about proper structure of code. In C/C++ I'd know how to do it with of h/hpp file.
<jhass>
the error just points out that if you forget to call setup WebCamArray's @logger is nil and you didn't handle that
<olek_poz>
I understand error, but it's the most proper way is to add every object as parameter of initialize method?
<jhass>
for most cases
<jhass>
after all your WebcamArray instance will be dysfunctional without the logger set
<jhass>
so it needs it to live so to say
<jhass>
the alternative is that you make it handle living without it, that is check logger isn't nil before calling methods on it
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<olek_poz>
I setup logger after initialize, before using them. And it would be more than okay for me, but it looks like it has to be initialized in 'initialize' method to works.
<jhass>
crystal doesn't know that you will always or even have always done it
<jhass>
it doesn't put all method calls into a global order and checks there's always something that sets a var before or something, that would take forever
<jhass>
and I even think doing so would a lot more annoying in the long term
<jhass>
because you reorder something and suddenly something probably only remotely and through 3 levels of abstractions becomes nilable
<jhass>
*remotely related
<jhass>
and then there's concurrency issues and meh
apt-get has joined #crystal-lang
brunto_ has joined #crystal-lang
<olek_poz>
In c++ if I do something wrong it will result in segfault. I'm not c++ pro coder, but using header file and assigning pointers at runtime worked fine. It looks like crystal allow only to assign in initialize method, and not later. The only exception are primitive objects.
brunto has quit [Ping timeout: 260 seconds]
apt-get has quit [Ping timeout: 256 seconds]
<jhass>
olek_poz: yes, Crystal aims to be a safe language
<olek_poz>
Ok. Thank you for info.
<jhass>
unless you explicitly touch unsafe parts (C bindings, :: and a few others), generating a binary that segfaults for another reason than a stack overflow is considered a compiler bug
Sadin has joined #crystal-lang
NeverDie has joined #crystal-lang
brunto_ has quit [Ping timeout: 240 seconds]
trapped has joined #crystal-lang
Ven has joined #crystal-lang
elia has quit [Quit: Computer has gone to sleep.]
alanwillms has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Client Quit]
olek_poz has quit [Ping timeout: 264 seconds]
leafybasil has joined #crystal-lang
Ven has joined #crystal-lang
leafybas_ has quit [Ping timeout: 260 seconds]
leafybasil has quit [Ping timeout: 244 seconds]
alanwillms has quit [Read error: Connection reset by peer]
Nik- has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ozra has joined #crystal-lang
<ozra>
Just saw the mention about `===` operator in #1730 - I can't find it in the manual. jhass: is there some doc somewhere, or could you explain it briefly?
<BlaXpirit>
i think it's literally just made with `case` in mind
<jhass>
yes, the Ruby term is "case equality", using it outside of implicitly in case/when and a few things like Array#grep is generally considered ugly
<BlaXpirit>
"would it make sense if it matched inside case"
<ozra>
ah. Super cool. That's what I would expect from that comparison.
<ozra>
Good way to put it.
<jhass>
it's a looser equality, unlike other languages who have both == and === where === is usually stronger
<ozra>
Yeah.
<ozra>
I think having == stronger, as in Crystal, (as discuseed in that issue) is better default.
<jhass>
yeah
<ozra>
Ok, then I grok it :) (sorry, reading Stranger In a Strange Land atm, so that expression sticks ;-)
<jhass>
though I have to agree that '.' == "." being true feels right still
<BlaXpirit>
nope
<ozra>
no
<ozra>
'.' === ".". I'm down with :)
<jhass>
it's hard to argue, thus I didn't participate
<ozra>
BlaXpirit: is there a term such as "conceptual equality"? I just made that up to explain atm, haha.
<BlaXpirit>
ozra, i wouldn't call it any kind of equality
<BlaXpirit>
it's just... matching
<ozra>
jhass: Yeah, I'm happy the way it is anyway.
<ozra>
BlaXpirit: Well put.
<ozra>
Oh, shit, ok, now I get it - '===' is implicitly used in 'case'. Good thing I learned this! Thanks for bringing my attention to it.
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 264 seconds]
bcardiff_ is now known as bcardiff
alanwillms has quit [Read error: Connection reset by peer]
alanwillms has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
<ozra>
I haven't realized till now that it's possible to write code directly in a class at root level. What purpose does this serve - any example?
<jhass>
probably mostly a legacy from Ruby
<jhass>
though allowing macro calls but normal crystal would be kinda weird
<jhass>
also calling calls methods of the parent class in the child class can be useful sometimes
<jhass>
er, *class methods
elia has joined #crystal-lang
<ozra>
alright. yeah, macros makes sense, but I just couldn't think of a good reason for run-time code..
trapped has joined #crystal-lang
Sadin has quit [Ping timeout: 252 seconds]
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<crystal-gh>
[crystal] asterite merged formatter into master: http://git.io/vC2yW
pawnbox has quit [Remote host closed the connection]
alanwillms has quit [Quit: This computer has gone to sleep]