mgarciaisaia1 has left #crystal-lang [#crystal-lang]
Liothen has quit [Changing host]
Liothen has joined #crystal-lang
oddmunds1 has quit [Ping timeout: 276 seconds]
oddmunds1 has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Philpax has joined #crystal-lang
snsei has joined #crystal-lang
Philpax has quit [Ping timeout: 265 seconds]
Philpax has joined #crystal-lang
Guest11464 has quit [Remote host closed the connection]
soveran has joined #crystal-lang
ssvb has joined #crystal-lang
soveran has quit [Ping timeout: 265 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 255 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 264 seconds]
soveran has joined #crystal-lang
ryanf has joined #crystal-lang
<ryanf>
is there a way to create a singleton object with a unique type?
<ryanf>
I want a pattern like scala's "sealed trait Foo; case class FooOne(anAttribute: String) extends Foo; case object FooTwo extends Foo"
soveran has quit [Ping timeout: 240 seconds]
<ryanf>
which is basically a union type where some members are singletons and others are classes
<ryanf>
I'm not sure what the nicest way in Crystal is to accomplish the same goal
eizua has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
<FromGitter>
<raydf> Hi ryanf, do you try any code in particular, maybe you could share a snippet in play.crystal-lang.org
soveran has joined #crystal-lang
Masaaki has joined #crystal-lang
<Masaaki>
How to debug a crystal program, does it have any tutorials?
<FromGitter>
<raydf> Masaaki you could output debug symbols at build time. But i haven't tested any tools with it, maybe someone else has more experience with debuging with symbols
soveran has quit [Ping timeout: 240 seconds]
<FromGitter>
<raydf> You can work as any dynamic language
matp_ is now known as matp
<FromGitter>
<raydf> using puts, pp, and interpolating variables with to_s or .to_json.
<Masaaki>
Sometimes error messages from runtime or compile-time are not friendly.
<FromGitter>
<raydf> Yes, there's a lot of work to be made before 1.0 release.
<FromGitter>
<raydf> could you share the error and maybe we could help you.
eizua has quit [Remote host closed the connection]
coderobe has quit [Remote host closed the connection]
coderobe has joined #crystal-lang
kulelu88 has joined #crystal-lang
masukomi has joined #crystal-lang
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<masukomi>
I went away for a few weeks and it appears "@foo = nil as String?" is no longer a thing. I tried replacing it with "@foo : String? = nil" and that seemed to mostly work but in one case i'm getting "instance variable @foo of ChangelogDatabase was inferred to be Nil, but Nil alone provides no information"
<masukomi>
not sure what the correct new syntax is and I'm not finding anything in the docs about initializing nils other than "@foo = nil"
<masukomi>
can anyone tell me what the new syntax is?
<masukomi>
@foo = nil.as(String?) ---- is that the new hotness?
<hellyeah>
i need to discover what crystal is about
snsei has joined #crystal-lang
<masukomi>
... about having the beauty of ruby combined with the benefits of static typing and fast runtime
<masukomi>
did that answer your question @hellyeah ?
<masukomi>
i'm really not getting why sometimes @foo : String? = nil is ok and sometimes it complains
<masukomi>
just been swapping the complainers to nil.as(String?)
<BlaXpirit>
masukomi, nah something is wrong. i mean, you did replace the syntax correctly
<BlaXpirit>
but .as(Anything?) seems weird
<masukomi>
i agree. i don't like it.
<masukomi>
I'll double check...
<BlaXpirit>
masukomi, you should proceed with `@foo : String? = nil` and then solve whatever problem comes next
<masukomi>
@found_path : String? = nil
<masukomi>
is giving me
<masukomi>
instance variable @found_path of ChangelogDatabase was inferred to be Nil, but Nil alone provides no information
<masukomi>
this is the entire method
<masukomi>
def initialize(@launch_dir : String)
<masukomi>
@found_path : String? = nil
<masukomi>
end
<BlaXpirit>
weird
<BlaXpirit>
masukomi, oh you're putting that inside the method?
<BlaXpirit>
you should put @found_path : String? outside the initialize
<masukomi>
oh.
<masukomi>
why does it make a difference?
<masukomi>
or more... why is what i was doing illegal
<BlaXpirit>
masukomi, i dunno, type annotations are not allowed inside methods
<masukomi>
but... what if i'm defining a local variable that only exists within the scope of the method?
<BlaXpirit>
masukomi, then you don't need type annotations at all
<masukomi>
that.... that doesn't sound right to me. I mean, how does it being inside a method change the fact that the compiler needs to know what's legal to assign to it or not
<masukomi>
are they like.. magically typed if limited to a single method?
<masukomi>
er.. magically dynamically typed instead of statically
<BlaXpirit>
masukomi, sounds like you haven't been here in the old days
<masukomi>
nah, i wasn't.
<masukomi>
to me the type annotations are always nice because they give other developers clues as to what to expect (regardless of if the compiler needs it or not)
<BlaXpirit>
Crystal has this algorithm that determines the smallest union of types that the variable could have at this point
<BlaXpirit>
in the past there were no type annotations even for instance variables!
<masukomi>
bah.
<BlaXpirit>
whatever types happen to appear in that spot are added to the union
<masukomi>
so, what's the argument for / thinking behind the current inconsisnency of sometimses you put 'em and sometimes you don't ?
<BlaXpirit>
that global magic is gone now
<masukomi>
<-- not a fan of inconsistence
<masukomi>
inconsistency ;)
<BlaXpirit>
but for locally scoped things it's totally cool
<BlaXpirit>
masukomi, what inconsistency in particular, i don't understand
<masukomi>
Sometimes crystal wants me to make type annotations, sometimes it gets mad at me for making them.
<masukomi>
i feel like they should always be acceptable even if not necessary
<BlaXpirit>
masukomi, it doesn't get mad at you
<BlaXpirit>
yes, maybe you're right that it should always be acceptable. but that's not the case right now
<BlaXpirit>
but the consistence is there, type annotations are simply not allowed in method bodies
<masukomi>
good to know. should i file a ticket with some (hopefully good) reasons why consistency is good and should be supported or is this a dead horse i'd just be beating more?
<BlaXpirit>
masukomi, don't phrase it with "consistency" because again, i still don't see anything inconsistent
<BlaXpirit>
i only agree that annotations for local variables should be supported
ponga has quit [Quit: Connection closed for inactivity]
<FromGitter>
<crisward> Anyone using crystal-db ?
<FromGitter>
<crisward> or json mapping?
<FromGitter>
<barisbalic> @crisward you mean the JSON mapping macro?
<FromGitter>
<crisward> yes
<FromGitter>
<barisbalic> I have used it, why's that?
<FromGitter>
<crisward> I'm using it to map out some database results. But I'd like to only return the results in the select, but I need the selected fields even if they're null.
<FromGitter>
<crisward> At the moment, I can only get it to return either all the fields in the map, or all the fields with a value.
<FromGitter>
<barisbalic> You can have nilable fields... do you have a gist you can share?
<FromGitter>
<crisward> I'll create one.
pawnbox has quit [Remote host closed the connection]
<FromGitter>
<barisbalic> Ahh okay, I thought you were deserialising JSON, then from what you just said, I would expect that to work.
<FromGitter>
<crisward> It does, but it doesn't give me null for the second company, just misses the field out. If I put `emit_null: true` on each field in the map I get null, but I get it every time, even if I don't select it.
<FromGitter>
<barisbalic> I will have to look at DB mapping to say any more, but that doesn't sound like it should happen
<FromGitter>
<crisward> I am sure you're right, just hoping for a quick answer from someone who's been there and done that. I'll play with their tests and see if I can re-create the issue.
hellyeah has quit [Ping timeout: 260 seconds]
<FromGitter>
<barisbalic> Okay sorry I couldnt be more help
Guest9173 is now known as adam12
soveran has joined #crystal-lang
<FromGitter>
<crisward> @barisbalic That's ok, I appreciate the help.
phase_ has quit [Remote host closed the connection]
phase_ has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
jamie-discord has joined #crystal-lang
jamie-discord is now known as jamie-discord1
jamie-discord1 has quit [Remote host closed the connection]
jamie_ca is now known as jamie_ca_
jamie_ca has joined #crystal-lang
phase_ has quit [Ping timeout: 255 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
Philpax has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
Philpax_ has quit [Ping timeout: 265 seconds]
<crystal-gh>
[crystal] asterite pushed 4 new commits to master: https://git.io/vixcX
<crystal-gh>
crystal/master 0328d97 Ary Borenszweig: String#rstrip: fixed potential unsafe access past string data
<crystal-gh>
crystal/master c1920c6 Ary Borenszweig: Removed extra comment
<crystal-gh>
crystal/master 5de901d Ary Borenszweig: Fixed #3341: incorrect cast behaviour on type change