asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
havenn has joined #crystal-lang
waterlink has quit [Ping timeout: 252 seconds]
havenwood has quit [Ping timeout: 255 seconds]
DerisiveLogic has joined #crystal-lang
strcmp1 has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 264 seconds]
zipR4ND has quit [Ping timeout: 255 seconds]
endou has quit [Read error: Connection reset by peer]
endou has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
havenn is now known as havenwood
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
a5i has quit [Quit: Connection closed for inactivity]
strcmp1 has quit [Ping timeout: 244 seconds]
ponga has joined #crystal-lang
BlaXpirit has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
JBat has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 248 seconds]
BlaXpirit has quit [Quit: Quit Konversation]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
panga has joined #crystal-lang
ponga has quit [Ping timeout: 256 seconds]
strcmp1 has joined #crystal-lang
panga has quit [Remote host closed the connection]
JBat has quit [Quit: Computer has gone to sleep.]
ponga has joined #crystal-lang
BlaXpirit has joined #crystal-lang
ponga has quit [Ping timeout: 245 seconds]
bcardiff has joined #crystal-lang
ponga has joined #crystal-lang
olog has joined #crystal-lang
olog has quit [Client Quit]
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ponga has quit [Remote host closed the connection]
ponga has joined #crystal-lang
a5i has joined #crystal-lang
Ven has joined #crystal-lang
<a5i> jhass, how can I accomplish this?
<jhass> I don't see a question there
<jhass> and please use gist
<a5i> jhass, well okay, basically I want a hash of GithubRepo's name and description
<a5i> the key of name and the value of description
<a5i> but I'm not quite sure how to access name and description from that class
<jhass> you call .name and .description on the instance
<jhass> repos.map {|repo| [repo.name, repo.description] }.to_h
<jhass> where repos = crystal_repos.items
<a5i> hmm
<a5i> I would replace Hash(GithubRepo.name, GitHubRepo.description) with crystal_repos.map {|repo| [repo.name, repo.description] }.to_h
<a5i> ?
<jhass> no
<a5i> a little confused :/
<jhass> you don't want to change the json_mapping's
<a5i> I'm not
<jhass> in your paste you were
<a5i> I only took some stuff I didnt want out
<jhass> no
<jhass> items: { type: Hash(GithubRepo.name, GitHubRepo.description) }
<jhass> that shouldn't even comple
<a5i> I know it doesnt, I put that there to show sort of what I wanted
<jhass> and I told you that you don't want to change the json_mapping's
<a5i> I was asking if I should swap it with: { type: Hash(crystal_repos.map {|repo| [repo.name, repo.description] }.to_h) }
<a5i> oh
<a5i> well then what should I do :S
<jhass> depends on what you actually want
<a5i> in the crystal shards code it shows that items is an array of whats in Githubrepo
<a5i> In my version I want items to have a hash of the name being the key and the value of the description
<jhass> GithubRepos has a property items which is an array of GithubRepo, if you mean that, yes
<jhass> you can't
<jhass> you can't change the json_mapping'
<jhass> it's mapping out what the json response from the API looks like, it's not defining how it should look like
<a5i> o
DerisiveLogic has joined #crystal-lang
bjmllr has quit [Ping timeout: 252 seconds]
JBat has joined #crystal-lang
asterite has joined #crystal-lang
<a5i> how can I index an Array(JSON::type) ?
<jhass> like any other
<jhass> why do you have one though?
<a5i> that last line returns an error since it says its nil
<jhass> wth do you do that
<jhass> GithubRepos.from_json(response.body).items.map {|repo| [repo.name, repo.description] }.to_h
BlaXpirit_ has joined #crystal-lang
<a5i> jhass, thanks, btw do you think a twitter account for crystal shards tweeting each new addition to the list is a worthwhile side project ?
<jhass> no idea, I don't use twitter
<a5i> o
BlaXpirit has quit [Ping timeout: 256 seconds]
ponga has quit [Quit: Leaving...]
asterite1 has joined #crystal-lang
asterite has quit [Ping timeout: 245 seconds]
shama has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit_> how to make HTTP GET request and obtain a string with the response content?
<jhass> require "http/client"; HTTP::Client.get("target").body
<jhass> iirc
<BlaXpirit_> cool, thx
<BlaXpirit_> well that's unfortunate. def initialize(vertex_shader_filename: String, fragment_shader_filename: String) def initialize(vertex_shader: String, fragment_shader: String)
<jhass> btw so far community standard, if you can call it that, is foo : Type, with a space before the :
<jhass> your variant trips but the Rubyist in me because it looks like 1.9 style hash syntax or keyword arguments :)
<BlaXpirit_> " : " is too much to ask
<jhass> wanted to try at least :P
<BlaXpirit_> of course, overloading on argument name doesn't work
<BlaXpirit_> there is only one language i know that has this
<BlaXpirit_> so i don't know what to do here
<jhass> how about: def self.from_files(vs_filename, fs_filename); new(load_file(vs_filename), load_file(fs_filename); end;
<jhass> (var names for brevity here)
<BlaXpirit_> I have a convention in my lib
<BlaXpirit_> of course, neither SFML nor CSFML use constructors for this kind of stuff.
<BlaXpirit_> but i do
<BlaXpirit_> i should just change everything to class methods...
<BlaXpirit_> so what's the convention on class methods that act like constructors?
<BlaXpirit_> or i can google "ruby class methods constructors"
<jhass> I'm not sure what you're asking for by "convention"
<BlaXpirit_> naming convention
<jhass> mh, don't think there's any
<jhass> use something that seems fit to your domain
<BlaXpirit_> from your example I can assume it doesn't have any prefix like "create" from file
<jhass> yeah, we tend to leave of prefixes
<jhass> for example with accessors: get_foo -> foo, set_foo -> foo=, is_foo -> foo?
<BlaXpirit_> oh while we're at it
<BlaXpirit_> if there is a setter foo=, should getter still be called foo?
<jhass> yes
<jhass> oh, you mean "foo?"
<BlaXpirit_> oh sorry, wasn't clear there
<BlaXpirit_> I mean "foo?"
<BlaXpirit_> basically i have is_foo, set_foo
<jhass> we haven't standardized that much yet, in Crystal I can see two conventions for question? methods
<jhass> if it's a flag or the like, name it foo?, a question? method should always return true or false and have no side effect if possible
<BlaXpirit_> well sure, it's just that a setter should be named "{{getter}}="
<jhass> and then in crystal we sort of have the "raise for foo, return nil for foo?" convention, though in stdlib it only applies to #[] and #[]? afaik
<jhass> ah, yeah, don't do foo?= (I think that's not even valid)
<BlaXpirit_> it's for that reason that I decided to not use `?` in my lib
<BlaXpirit_> but i'll add itr
<jhass> in Ruby I see it 50/50 like this: some provide the accessor only as foo? if it makes sense, some alias the regular accessor to foo?, so you have foo and foo? as the same thing
<BlaXpirit_> alias, huh
<BlaXpirit_> isn't it clutter?
<jhass> Ruby stdlib has many aliases
<jhass> inject/reduce, select/find_all, find/detect to name just a few
<BlaXpirit_> i don't like that, now that i think about it
<jhass> I haven't really settled yet as to which variant I prefer
<jhass> but actually I think foo? only, if it's a flag, makes sense
<jhass> cool :)
HakanD__ has joined #crystal-lang
<asterite1> BlaXpirit_: what language has overloads based on args names?
<BlaXpirit_> nim
<asterite1> So there you are forced to use args names on the call?
<BlaXpirit_> yes
<asterite1> I mean, because of the ambiguity
<asterite1> Interesting
<BlaXpirit_> discovered it by accident because of this same mishap that i mentioned
<jhass> asterite1: btw I really like the idea of being able to use keyword args in the caller for required args too, in fact I wanted to suggest it sometime before you mentioned it
c355E3B has joined #crystal-lang
<asterite1> Yes, I think I'd like that too. The only downside is that it ties the names to every API
<asterite1> but I guess you'd use that when you have many (3 or more?) arguments, and so you'll be careful to choose good names
c355E3B has quit [Quit: Leaving]
c355E3B has joined #crystal-lang
a5i has quit [Quit: Connection closed for inactivity]
asterite has joined #crystal-lang
asterite1 has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vfEXT
<crystal-gh> crystal/master 340389b Ary Borenszweig: Fixed a case of special vars
HakanD__ has quit [Quit: Be back later ...]
<travis-ci> manastech/crystal#2255 (master - 340389b : Ary Borenszweig): The build is still failing.
BlaXpirit_ has quit [Quit: Quit Konversation]
asterite has quit [Quit: Leaving.]
JBat has quit [Quit: Computer has gone to sleep.]
Exilor has joined #crystal-lang
Exilor has quit [Client Quit]
Excureo has quit [Ping timeout: 250 seconds]
Excureo has joined #crystal-lang
ssvb has quit [Ping timeout: 256 seconds]
a5i has joined #crystal-lang
ssvb has joined #crystal-lang