ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
duane has quit [Ping timeout: 244 seconds]
<FromGitter> <watzon> Why can't I get the `read_file` macro to work?
<FromGitter> <watzon> ```code paste, see link```
<FromGitter> <Blacksmoke16> code?
<FromGitter> <watzon> ```@@data = read_file(File.join(__DIR__, "../../data/sentiment.txt"))```
<FromGitter> <Blacksmoke16> yea thats not how it works
<FromGitter> <Blacksmoke16> thats now in macro land
<FromGitter> <watzon> Ahh shit
<FromGitter> <watzon> Lol
<FromGitter> <Blacksmoke16> gotta do like `{{read_file "../../data/sentiment.txt"}}`
<FromGitter> <watzon> That makes sense
<FromGitter> <girng> ROFL (https://i.imgur.com/ts6mXiK.jpg)
mistergibson has quit [Quit: Leaving]
<FromGitter> <girng> Damnnnnnnnnnnnnnnnnnn
duane has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <watzon> Is there any way to constrain a generic to one type? I'm pretty sure the answer is no, but I'm curious
<FromGitter> <watzon> For instance `Class(T)` would just allow one type, not unions
<FromGitter> <Blacksmoke16> `{% raise "Some error" unless T == String %}`
<FromGitter> <Blacksmoke16> something like that
<FromGitter> <watzon> I guess I could do the same with unions huh?
<FromGitter> <Blacksmoke16> `{% raise "Some error" unless T.is_a?(Union) %}`
<FromGitter> <mwlang> sure. that's easy. Write code for *only* one type and no others. :snark remark: :-D
<FromGitter> <watzon> Hmm the `T.is_a?(Union)` part doesn't work for some reason
<FromGitter> <Blacksmoke16> where you putting it?
duane has quit [Ping timeout: 272 seconds]
<FromGitter> <watzon> Ahh
<FromGitter> <watzon> `T.union?`
<FromGitter> <watzon> That's what I needed
<FromGitter> <mwlang> (takes notes...)
<FromGitter> <Blacksmoke16> right because you're dealing with literals in macro land
<FromGitter> <Blacksmoke16> makes sense
<FromGitter> <watzon> Yuppers
<FromGitter> <elorest> Did any of you guys from Argentina watch the eclipse?
<FromGitter> <elorest> As a vim user I it's too painful for me to try searching the channel for "eclipse"
<FromGitter> <Blacksmoke16> `eclipse -ide`
<FromGitter> <Blacksmoke16> tada :P
<FromGitter> <elorest> @Blacksmoke16 does starting eclipse with the `-ide` flag change anything?
<FromGitter> <Blacksmoke16> oh, i thought you meant search google
<FromGitter> <Blacksmoke16> which would search for `eclipse` but remove any results that are related to the ide
<FromGitter> <elorest> Got it. I should have noticed that. My head was still stuck in the terminal lol.
<FromGitter> <elorest> I'm sure I could find some great stuff on youtube about the 2019 eclipse but since it went right though Argentina I figured some friends here may have seen it.
<FromGitter> <tenebrousedge> neat
<FromGitter> <tenebrousedge> that's such an amazing experience
<FromGitter> <girng> some of the best devs active the open source community are from argentina
asterite has quit [Ping timeout: 276 seconds]
jhass has quit [Ping timeout: 276 seconds]
jhass has joined #crystal-lang
asterite has joined #crystal-lang
<FromGitter> <girng> ROFL
<FromGitter> <girng> I just spent 40 minutes trying to find this bug on why i wasn't hitting a monster (not registering on the server)
<FromGitter> <girng> then i realized, i have 85% chance to hit i added that in last week
<FromGitter> <girng> πŸ˜†
ht_ has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
snsei__ has joined #crystal-lang
return0e has joined #crystal-lang
asterite has quit [Ping timeout: 246 seconds]
<FromGitter> <watzon> Can someone explain to me why they do this (https://github.com/ruby/ruby/blob/v2_5_0/lib/matrix.rb#L245) in Ruby?
jhass has quit [Ping timeout: 264 seconds]
DTZUZO has joined #crystal-lang
return0e has quit [Ping timeout: 244 seconds]
jhass has joined #crystal-lang
asterite has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter> <yxhuvud> `send` can call private methods. But why anyone would code like that, no.
return0e has joined #crystal-lang
<FromGitter> <watzon> Ahh yeah that makes sense I gues
jhass|off has joined #crystal-lang
jhass has quit [Ping timeout: 264 seconds]
asterite has quit [Ping timeout: 252 seconds]
jhass|off is now known as jhass
asterite has joined #crystal-lang
<FromGitter> <watzon> I wish stack overflow messages could be a little more helpful
<FromGitter> <girng> one problem i faced in programming (want to post to see if anyone else has gone through this phase)
<FromGitter> <girng> when trying to implement something, you think of doing it in code first. but you are really supposed to think on how to implement its logic first and what it's supposed to do, before coding it
<FromGitter> <girng> anyone else done that before? kinda makes it hard sometimes doesn't it?
<FromGitter> <girng> when i say "doing it in code first" i mean, "can this programming language support this kind of idea / functionality?"
<FromGitter> <girng> but in reality, most programming languages do... so it's the matter of the thinking about the idea and its logic first. once you got that down, code the damn thing
<FromGitter> <watzon> I'm pretty sure everyone does that at some point
<FromGitter> <girng> i don't think writing out logic (if blocks, case/when, class, etc) is the hard part, it's the concept and logic behind it. that's the hard part.
jhass has quit [Ping timeout: 248 seconds]
asterite has quit [Ping timeout: 248 seconds]
snsei__ has quit [Remote host closed the connection]
<FromGitter> <spTorin> Trying to use the options parser. If you specify a flag with an option, such as in the documentation for the parser: `parser.on (" - t NAME "," --to = NAME "," Specifies the name to salute ") {| name | destination = name} `. And if you use this flag without the option - just `-t`, then the exception is `Unhandled exception: Missing option: -t (OptionParser :: MissingOption) ......`. Where can I catch an
<FromGitter> ... exception and how to do it correctly? You just need to display that the `-t` flag has no argument.
snsei__ has joined #crystal-lang
sorcus has joined #crystal-lang
<FromGitter> <j8r> How can I check if a char is a valid UTF8 one?
<FromGitter> <spTorin> @j8r ascii?
<FromGitter> <spTorin> 'a'.ascii?
<FromGitter> <spTorin> @j8r If you have char - it already valid. Invalid as UTF8 may be a sequence of bytes.
snsei__ has quit [Ping timeout: 252 seconds]
<FromGitter> <j8r> To necessarily, I do `1.unsafe_chr` for instance
jhass has joined #crystal-lang
asterite has joined #crystal-lang
snsei__ has joined #crystal-lang
snsei__ has quit [Ping timeout: 276 seconds]
davic has quit [Remote host closed the connection]
davic__ has joined #crystal-lang
OvermindDL1 has quit [*.net *.split]
mntmn has quit [*.net *.split]
issyl0 has quit [*.net *.split]
lesderid has quit [*.net *.split]
davic__ has quit [Quit: ZNC - http://znc.in]
lesderid has joined #crystal-lang
<FromGitter> <Blacksmoke16> @spTorin you defined the arg as `- t NAME` not `-t NAME`
issyl0 has joined #crystal-lang
mntmn has joined #crystal-lang
OvermindDL1 has joined #crystal-lang
go|dfish has quit [Ping timeout: 248 seconds]
duane has joined #crystal-lang
go|dfish has joined #crystal-lang
duane has quit [Ping timeout: 268 seconds]
laaron has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
laaron has joined #crystal-lang
duane has joined #crystal-lang
snsei__ has quit [Ping timeout: 252 seconds]
DTZUZO has quit [Ping timeout: 245 seconds]
DTZUZO has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> @j8r could you use https://crystal-lang.org/api/master/Char.html#ascii%3F-instance-method ?
lucasb has joined #crystal-lang
snsei__ has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <naqvis> `URI` Parser is broken, as its accepting invalid URIs happily. below snippet works fine ⏎ ⏎ ```URI.parse("//white space”) ``` [https://gitter.im/crystal-lang/crystal?at=5d24a91d270d2b1bfa680340]
<FromGitter> <j8r> @Blacksmoke16 ascii != UTF8
<FromGitter> <j8r> the codepoints can go far beyond 128
<FromGitter> <Blacksmoke16> could do something similar tho?
DTZUZO has quit [Ping timeout: 245 seconds]
<FromGitter> <j8r> no, it doesn't even validate the Char
<FromGitter> <j8r> it does an `ord < 128`
<FromGitter> <Blacksmoke16> but isnt that fact that its a Char, means its already valid?
<FromGitter> <j8r> my usecase it to have a list of all BasicLatin Chars, or all Emojis, etc
<FromGitter> <Blacksmoke16> whats an example of an invalid char?
<FromGitter> <j8r> valid I don't know, but can be "empty": ⏎ ⏎ ```i = 0 ⏎ while i < 128 ⏎ puts i.unsafe_chr ⏎ i += 1 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d24ab29bea9f3574123ea91]
<FromGitter> <Blacksmoke16> what about using https://crystal-lang.org/api/master/Int.html#chr-instance-method and catching the exception?
<FromGitter> <j8r> no difference
<FromGitter> <j8r> it just check if `i` is between 0 and another bigger one
<FromGitter> <Blacksmoke16> isnt that what you want? that a character is within the range of a valid utf-8 char tho?
<FromGitter> <j8r> yes put for example `puts 1.chr` print is blank
<FromGitter> <j8r> I would like to know if the char results of a blank print or not
<FromGitter> <j8r> I know it may vary of the client, depending its support of UTF8
<FromGitter> <Blacksmoke16> right but its still a valid utf8 char no?
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> I guess that's `Char#control?`
<FromGitter> <Blacksmoke16> yea could just filter those out if you only want the printable chars
<FromGitter> <spTorin> @Blacksmoke16 >> you defined the arg as `- t NAME` not `-t NAME` ⏎ it copy-paste error, I try with code from docs.
<FromGitter> <spTorin> copy code from https://devdocs.io/crystal/api/0.27.0/optionparser and run it with `-f`
<FromGitter> <Blacksmoke16> there isnt a `-f` arg registered on the parser, so you're going to get that error
<FromGitter> <Blacksmoke16> so its hitting the `invalid_option` block
<FromGitter> <spTorin> Of course, but how can I handle this and not fall into the exception when the user enters only the key `-f`
<FromGitter> <Blacksmoke16> ``` parser.invalid_option do |flag| ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d24b47f17cc7b05ca9c7ad4]
<FromGitter> <Blacksmoke16> just dont do anything when there is an invalid option
<FromGitter> <Blacksmoke16> or add another `parser.on` with the `-f` option
<rkeene> Doing interviews and technical interview person asked for preferred languages... tempted to list Crystal
rohitpaulk has quit [Remote host closed the connection]
<rkeene> Also heading to Seattle right now (at the airport)
<FromGitter> <spTorin> but just `-f` not call `parser.invalid_option { }` because it's not invalid option - and throw ex
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d24b551b0027d2b19a006ac]
<FromGitter> <Blacksmoke16> ```./test -f ⏎ Hello World!``` [https://gitter.im/crystal-lang/crystal?at=5d24b558d0e06b6675750963]
<FromGitter> <Blacksmoke16> works fine?
<FromGitter> <spTorin> Omg, sorry! I use in my prog key `-f FILE` and say it here. For docs use `-t`
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <spTorin> ```./test -t```
<FromGitter> <Blacksmoke16> yea because it is expecting a value
<FromGitter> <Blacksmoke16> `./test -t John`
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/OptionParser.html#missing_option%28%26missing_option%3AString-%3E%29-instance-method so it would be a diff handler
<FromGitter> <spTorin> Yes! Exactly what I need! Read this doc, but scroll down `missing_option`. Tnx!
<FromGitter> <Blacksmoke16> np
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
DTZUZO has joined #crystal-lang
ht__ has joined #crystal-lang
ht_ has quit [Ping timeout: 250 seconds]
ht__ is now known as ht_
sagax has quit [Ping timeout: 272 seconds]
DTZUZO has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
sagax has joined #crystal-lang
Raimondi has quit [Ping timeout: 258 seconds]
Raimondi has joined #crystal-lang
absolutejam1 has joined #crystal-lang
Raimondi has quit [Ping timeout: 258 seconds]
Raimondi has joined #crystal-lang
rohitpaulk has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Ping timeout: 272 seconds]
ht_ has quit [Quit: ht_]
<FromGitter> <watzon> Is anyone particularly familiar with the inner workings of `pretty_print`?
<FromGitter> <Blacksmoke16> for json?
<FromGitter> <watzon> Just period. Overriding the `def pretty_print` on Objects
<FromGitter> <watzon> Currently I have this for my Matrix class ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d24f873bea9f35741261f24]
<FromGitter> <watzon> Which works fine, but with smaller matrices it prints all the columns in one row
<FromGitter> <watzon> i.e `pp Matrix.identity(2)` would print `[[1, 0], [0, 1]]`
<FromGitter> <watzon> I want it to always do what it does with larger matrices ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d24f8e8f5dd14574256f48e]
<FromGitter> <Blacksmoke16> it prob would but only has the 1 row
<FromGitter> <Blacksmoke16> er nvm
<FromGitter> <watzon> I just don't know enough about `pretty_print` to get it working correctly
RyanMcCoskrie has joined #crystal-lang
<FromGitter> <girng> @rkeene really? i live near tacoma
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <girng> @rkeene good luck! i have crystal on my resume
<FromGitter> <watzon> Haha I use to live up there
<FromGitter> <watzon> Not around Tacoma really, but in a small town called Naselle
<FromGitter> <girng> oh nice, near the ocean ;p
<FromGitter> <watzon> Yup!
<FromGitter> <watzon> I miss it, but my allergies don't
<FromGitter> <girng> i was thinking abou t moving out and starting a new life with the money i saved from working at costco. but i gave all that money to my mom already, i think im just stuck here
<FromGitter> <girng> anyways, cost of living over here is pretty insane. a 1000sqft house is $250,000
<FromGitter> <girng> pacific northwest is cancer to live in unless you live with a roomate, leech off parents, or work 50 hours a week
<FromGitter> <watzon> Yeah, cost of living in the US period is pretty stupid
<FromGitter> <watzon> My wife and I are going to move to Guatemala before the end of the year
<FromGitter> <girng> which will ruin a person's morale and diminish any kind of hobbies they want to do. spend time with kids, etc.
<FromGitter> <girng> @watzon nice
<FromGitter> <girng> @watzon east coast of wa state is really nice too. but i heard it's really hot lol. bet it's pretty hot in Guatemala too
<FromGitter> <watzon> Actually Guatemala is pretty much perfect all year 'round
<FromGitter> <watzon> High 60s to low 70s
<FromGitter> <girng> o really
<FromGitter> <girng> not bad
<FromGitter> <watzon> And it's beautiful
<FromGitter> <girng> that's really good temps
<FromGitter> <watzon> Asked my `pretty_print` question in the forum if anyone knows how to help https://forum.crystal-lang.org/t/pretty-printing-a-matrix/930
laaron- has joined #crystal-lang
laaron has quit [Ping timeout: 260 seconds]
duane has quit [Ping timeout: 272 seconds]
duane has joined #crystal-lang
RyanMcCoskrie has quit [Remote host closed the connection]
<FromGitter> <wontruefree> use to live east of seattle I miss it
<FromGitter> <wontruefree> but there is no way I would want to spend that kind of money again
sorcus has quit [Ping timeout: 252 seconds]
gangstacat has joined #crystal-lang
<FromGitter> <girng> nice, i didn't know that many people in this crystal community used to live in wa state lol
<FromGitter> <mwlang> @watzon Looks like Crystal takes similar approach as Ruby and has a PrettyPrint class. Looks like you can control width of output with this: https://crystal-lang.org/api/0.21.1/PrettyPrint.html
<FromGitter> <watzon> I'm aware of that, and that's what I'm doing. I just don't know how to make it return the output I want.
<FromGitter> <asterite> I think you should just `text("\n")` if you always want a newline
<FromGitter> <watzon> I feel like I've tried that and it had a really ugly output, but I'll try again
absolutejam1 has quit [Ping timeout: 272 seconds]
<FromGitter> <asterite> (disclaimer: I know nothing about pp)
<FromGitter> <watzon> Yeah I have no idea
<FromGitter> <watzon> I've tried everything I can think of