Jomakasi has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 246 seconds]
triangles2 has joined #crystal-lang
triangles has quit [Ping timeout: 260 seconds]
<FromGitter>
<drosehn> Could someone remind me of a standard trick? I'm trying to do the following command, and it's failing because the second reference to instance-variable `@locationKey` *could* be nil. I understand why crystal complains about that, and I know there was a standard shorthand-way to avoid it, but I can't remember what the shorthand is. The example statement is:
<FromGitter>
<drosehn> ah, yeah, that's probably it.
pawnbox has joined #crystal-lang
matp has quit [Quit: Bye!]
matp has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
<FromGitter>
<johnjansen> @drosehn did you get it ? `lsize = locationKey.try &.size || 0`
<FromGitter>
<drosehn> I did try it, and it does work. But I think I'll stick with the dumb-copy for now. There are times when I'll test a few lines of code by copy&pasting it into `irb`, and the dumb-copy works in ruby but the `try &` shorthand doesn't.
<FromGitter>
<drosehn> However I'm at least going to put that method in as comments, so I can find it the next time I'm looking for it! :smile:
<Papierkorb>
BlaXpirit: Thanks, will maybe add it later this week
soveran has joined #crystal-lang
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37 has joined #crystal-lang
vonKingsley has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pduncan has quit [Ping timeout: 260 seconds]
<vonKingsley>
quick Q, I'm reviewing macros and curious if there are there any other instance variables, or is @type the only one?
<BlaXpirit>
vonKingsley, there are none (99% sure)
<vonKingsley>
Thanks, i searched around and couldnt find any, but figured i would ask
vonKingsley has quit [Quit: Page closed]
<FromGitter>
<drosehn> I'm working with the JSON support for the first time. The `mapping()` macro combined with ".from_json" method has saved me a ton of work. The one thing I can't figure out is how I could set `strict = true`. I'm reading in a file of json objects which was written out by a program that I have no documentation for, so I want to know if my code has missed some field in that object.
<FromGitter>
<drosehn> Huh. I didn't realize I was supposed to have curly-braces in there. Let me try that.
<FromGitter>
<drosehn> Yes! Thanks muchly!
<Papierkorb>
cheers
<RX14>
you don't need curly braces
<FromGitter>
<drosehn> (and yes, there is at least one field that I had overlooked)
<RX14>
but you do need them if you specify strict: true
<FromGitter>
<drosehn> Ah.
Philpax has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 264 seconds]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
<FromGitter>
<drosehn> Yep, that worked nicely. And these are files with thousands of lines, and some of those lines are > 4000 characters. Kinda hard to eyeball them to see what fields are defined!
vikaton has quit [Quit: Connection closed for inactivity]