baweaver changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://gist.github.com | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
patr0clus has joined #ruby
apeiros has joined #ruby
desperek has quit [Quit: xoxo]
fmcgeough has quit [Quit: fmcgeough]
Freshnuts has quit [Ping timeout: 264 seconds]
elphe has quit [Ping timeout: 264 seconds]
edwardly has quit [Ping timeout: 240 seconds]
edwardly has joined #ruby
patr0clus has quit [Quit: WeeChat 2.1]
<baweaver> So I had a bad idea
<baweaver> How can I get something to pretend it's Object without overwriting Object methods?
<baweaver> Such that: 1.is_a?(Any) -> true
<baweaver> `is_a?` returns true if the class is anywhere in its ancestary.
<baweaver> >> Any = Object; 1.is_a?(Any) # This works, sure, but....
<ruby[bot]> baweaver: # => true (https://eval.in/1044764)
cagomez has quit [Remote host closed the connection]
<baweaver> >> Any = Object; def Any.===(o) true end; Any === 1 # This seems to crash
<ruby[bot]> baweaver: # => true (https://eval.in/1044765)
<baweaver> Oh, so just Pry, though I feel like that overrides the base.
<baweaver> Yeah, it flips out IRB too.
<baweaver> havenwood / apeiros: help me do bad things to Ruby again
elphe has joined #ruby
<havenwood> baweaver: Ah, interesting.
<havenwood> baweaver: hmm
<havenwood> baweaver: Object.method(:===).owner #=> Module
<havenwood> BasicObject.method(:===).owner #=> Module
<havenwood> Object === Pry::Config.new #=> false
<baweaver> IRB goes straight into an infinite loop
<baweaver> Waitasecond
<baweaver> How does a class know its own name?
<baweaver> If there were a way to cheat and tap that, making it think it's an "Object" then...
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<baweaver> havenwood: Got a new idea
<baweaver> Circus theme, Indigo as the ring master, cue: The Most RSpectacular Show on Earth!
<baweaver> Each of the rings correspond to one type of testing
<baweaver> Unit, Integration, Acceptance
banisterfiend has joined #ruby
<havenwood> baweaver: "moar tests!" roared the lion!
<baweaver> Testy testy aren't you?
<havenwood> "rwar tests" roared zenspider!
<baweaver> I'd kinda like to give "Reducing Enumerable - An Illustrated Guide" a few more runs before I start on another super ambitious presentation
<havenwood> no doubt
<baweaver> That said, I'm also massively faster now in preparing them
dviola has quit [Quit: WeeChat 2.2]
this_dude has joined #ruby
<this_dude> anyone online?
<baweaver> perhaps
<this_dude> trying to code a method to do the following: Write a method that takes in a string of lowercase letters and # spaces, producing a new string that capitalizes the first letter of each word
<this_dude> running across some trouble
<baweaver> What have you tried
<this_dude> do i post my code so far on the github?
<baweaver> Yeah, that should work.
<this_dude> oh do i need to be registered or something?
<this_dude> may pm?
<baweaver> channel is fine
<this_dude> its more than 3 lines D:
<baweaver> Ah
<baweaver> Some people have used that
<this_dude> ok i posted what i have so far
<this_dude> obvious its wrong as i keep returning an "undefined local variable or method" error
<this_dude> but idk where to go from there..
<baweaver> link?
moei has quit [Quit: Leaving...]
<this_dude> actually here ...to make our lives easier
<havenwood> ?gist
<ruby[bot]> https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
<this_dude> idk how to use the gist link
<baweaver> So you want to capitalize every word then?
<this_dude> yeah basically
<baweaver> >> 'this is a sentence'.split(' ') # This gets you an array of words
<ruby[bot]> baweaver: # => ["this", "is", "a", "sentence"] (https://eval.in/1044766)
<this_dude> mhm
<baweaver> >> 'this is a sentence'.split(' ').map { |w| w.reverse } # With it you can map it to transform each word
<ruby[bot]> baweaver: # => ["siht", "si", "a", "ecnetnes"] (https://eval.in/1044767)
<this_dude> o.o
<havenwood> >> 'this is a sentence'.split.map(&:reverse) # Or a slightly shorter version that does the exact same thing as above.
<ruby[bot]> havenwood: # => ["siht", "si", "a", "ecnetnes"] (https://eval.in/1044768)
<baweaver> >> 'this is a sentence'.split(' ').map { |w| w.reverse }.join(' ') # That you can then join back together
<ruby[bot]> baweaver: # => "siht si a ecnetnes" (https://eval.in/1044769)
<baweaver> Yep, havenwood is correct that you can shorthand it as well
<this_dude> im unfamiliar with that syntax
<this_dude> but i dont need to reverse the words
<this_dude> i need to capitalize the first letter of each one
<baweaver> You could do anything in map
<havenwood> this_dude: It's similar to what you're doing, but not the exact solution.
<this_dude> ohhhh
<this_dude> so
<this_dude> .upcase
<this_dude> instead of .reverse?
<this_dude> wait no cause that'll capitalize the whole word
<havenwood> this_dude: Compare #upcase, #downcase, #capitalize, and #swapcase.
<baweaver> Try it out.
<baweaver> wasn't capitalize Rails?
<this_dude> um
<this_dude> is this not ruby on rails
<baweaver> Well, a Rails only method. It's not.
<this_dude> uhoh
<baweaver> Some methods are only in Rails (or activerecord)
<this_dude> is there a rails chat?
<baweaver> >> 'string'.capitalize
<ruby[bot]> baweaver: # => "String" (https://eval.in/1044771)
<havenwood> this_dude: #RubyOnRails
<havenwood> 18>> 'string'.capitalize
<baweaver> though you don't need it.
<ruby[bot]> havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> bot go boom
<havenwood> But yeah, it's been in Ruby core since forever.
<this_dude> wtf
<this_dude> so
<this_dude> in my case where I need "string".upcase
<this_dude> is it not the same as .capitalize?
<havenwood> this_dude: Try in irb or pry.
<baweaver> Try it out in IRB on your computer
<baweaver> ninja
<havenwood> ?irb
<ruby[bot]> irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
<this_dude> ok gimme a sec
<havenwood> ?pry
<ruby[bot]> Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
<this_dude> i have ruby already installes
<this_dude> installed*
<this_dude> gimme a sec to run the code
<this_dude> is this syntax written correctly? http://prntscr.com/kf3hcg
<havenwood> this_dude: One of the reasons to show us text and not an image is that we can then easily run your code.
<this_dude> but how can i do that if im not allowed to put more than 3 lines D:
<this_dude> how do i use the gist thing
<havenwood> Where was Radar's gist about how to gist?
<havenwood> That was goodl
<this_dude> oh i do have to sign up
<this_dude> smh gimme a sec
<havenwood> this_dude: Gists are nice because we can then comment, clone the gist, propose modifications, etc.
<this_dude> bruh "password has been compromised in a 3rd party data breach"
<this_dude> um excuse me
<this_dude> now im scared smh
<havenwood> Time to start using a new password.
<havenwood> Someone lost the keys to the castle.
<this_dude> bruh it was a secure password too
<this_dude> thats what i get for using the dark web
<this_dude> there ya go
<baweaver> So you know how split and map works
<baweaver> what if you replaced reverse with something else?
<this_dude> i dont think that syntax you used works in rails does it?
<this_dude> { |w| w.reverse }
<this_dude> idk how this works
<this_dude> it wasnt in the material provided to study for my entrance exams..
<havenwood> this_dude: Ruby syntax always works in Rails.
<havenwood> this_dude: Blocks might not have been on your entrance exam.
postmodern has quit [Quit: Leaving]
<this_dude> oh look
ansraliant has joined #ruby
alex`` has quit [Ping timeout: 244 seconds]
postmodern has joined #ruby
<baweaver> map, select, find, and reduce are some of the most powerful methods in Ruby.
<baweaver> ignoring them is a bit silly.
<this_dude> its a beginner level entrance exam D:
<baweaver> >> [1,2,3].map { |v| v * 2 }
<ruby[bot]> baweaver: # => [2, 4, 6] (https://eval.in/1044772)
<this_dude> i was given 10 days to learn the basics enough to pass 2 entrance exams
<this_dude> im on day 4
<baweaver> Map takes a function ({ |v| v * 2 })
<baweaver> and runs it for every element
<this_dude> what is the "v"
<this_dude> random name for the array?
<baweaver> In javascript it may look like this: function (v) { return v * 2; }
<baweaver> v is the argument to the function
<baweaver> v * 2 is what it does with it
<this_dude> okay and earlier you used w
<this_dude> whats the difference
<baweaver> It could be anything
<baweaver> >> [1,2,3].map { |anything| anything * 2 } # depending on how literal you want to be
<ruby[bot]> baweaver: # => [2, 4, 6] (https://eval.in/1044773)
<this_dude> so its like i said..a random naming of the arra
<this_dude> array*
<this_dude> ie anything [1,2,3]
<baweaver> not the array, but rather each element of it
<this_dude> oh wtf
<this_dude> for example
<this_dude> i=0
<this_dude> and then incrementing i
<this_dude> right?
<baweaver> each element that goes into the function is named 'v' for you to use
<this_dude> okay i get it
<baweaver> there is no i
<this_dude> i==idx
<baweaver> even still, there is no i there.
<this_dude> you cant use i?
Creatornator has joined #ruby
<this_dude> so uh
<this_dude> in my code i completely removed the word "string" but im still getting an error that says "Did you mean: String?"
<this_dude> oh i resolved that
<this_dude> forgot a gets statement
mikecmpbll has quit [Quit: inabit. zz.]
<baweaver> That should show you how map, select, and find work
<this_dude> oh youre using repl.it too?!
<baweaver> If you know those three you basically have superpowers.
<this_dude> this is the problem im working on
<baweaver> split, map, capitalize, join
<baweaver> that's all you need
<this_dude> this is the solution provided
<this_dude> oh wow that was easier than i made it seem wtf
<baweaver> It's a silly solution
<baweaver> you can do it in one line easily, and it's perfectly legible.
<this_dude> how
<this_dude> what would the one line code for it be
<baweaver> you have the tools
<this_dude> hmm ok
<this_dude> let me try to figure it out
<this_dude> [string.split].map { |v| v.upcase }
<this_dude> ?
<this_dude> after def capitalize_words(string)
<baweaver> was upcase one of the words mentioned?
<this_dude> wdym
<baweaver> split, map, capitalize, join
<baweaver> that's all you need
<this_dude> ohh true
<this_dude> okok
<this_dude> [string.split].map { |v| v.capitalize }
<baweaver> why the array brackets?
<baweaver> and what about join?
<this_dude> here let me actually write out the code brb
<havenwood> this_dude: I wrote you some tests, if you'd like to try them: https://gist.github.com/havenwood/a46712ea8df08c6da46cd2707b4efb1b
<this_dude> like practice problems?
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> this_dude: Yup, the tests will all fail and you can make them all pass.
<havenwood> this_dude: You can save the contents of that gist as `capitalize_words.rb` then run the tests with: ruby capitalize_words.rb
<havenwood> this_dude: Then try just an `s` inside the method and you'll see two tests now pass.
<this_dude> def capitalize_words(string) (string.split(" ")).map { |v| v.capitalize} string.join
<this_dude> like this?
<this_dude> string.join(" ")*
<baweaver> try it
<baweaver> your REPL will answer more questions faster than we can.
<this_dude> theres already code that they provide to see if it works
<this_dude> ok brb
<this_dude> idk how to join it back
<this_dude> ik how to do .split(" ")
<this_dude> but idk how to join it back and put the spaces back in
<baweaver> every method returns a value
<this_dude> .join always confuses me
<baweaver> who's to say you can't chain them all together?
<baweaver> What does join do?
kapil___ has joined #ruby
<this_dude> joins an array into a string
<baweaver> >> 'this is a sentence'.split(' ').map { |w| w.reverse }.join(' ') # That you can then join back together
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> What's that doing?
<baweaver> bot be broke
<this_dude> you can do that in the same line???
<this_dude> wtf ok brb
<baweaver> yep
<this_dude> getting an error
<this_dude> wow nvm
<this_dude> i got it
<this_dude> thats stupid easy
<this_dude> idk why they dont teach that
<this_dude> string.split(" ").map{ |v| v.capitalize}.join(" ")
<this_dude> literally in one line thats so dumb
<baweaver> and once you understand those three methods (select, map, and find) you're well ahead already.
<baweaver> Hence us chuckling a bit about the proposed solution
<baweaver> Give that a read through
<this_dude> wow ruby syntax is alot stronger than i thought it was
<this_dude> i literally did what they put in like 15 lines...in 1 line
<this_dude> whats that?
<baweaver> It explains one of the most powerful functions in Ruby
<baweaver> reduce
<this_dude> wait let me ask you a question then
<baweaver> Triple Equals is the other super power in Ruby - https://medium.com/rubyinside/triple-equals-black-magic-d934936a6379
<this_dude> could i use that .map function for another problem on there...the caesar cipher?
<havenwood> this_dude: yes
<this_dude> oh yeah i saw something on an article about the triple equals
<baweaver> map is generic.
<baweaver> It operates on any Enumerable type, and returns a new Array
<this_dude> dude if i go into these exams using advanced ruby code im sure to get into the program lmao
<this_dude> i love you guys
<baweaver> These are the basic building blocks, there's still more to learn, but once you have these building blocks down it unlocks a ton.
<this_dude> ok so let me try to code the caesar cipher using that then...cause the exam is supposedly gonna only go up to the "medium difficulty" category questions and the cipher is in the "hard" category
<baweaver> What's funny about Caesar and ROT13 is they can be done in a handful of characters
<baweaver> barely even a full line worth.
<baweaver> but I'd use map for now.
<baweaver> well, rather I'd use map, ord, and modulo.
<baweaver> the way that'd be a bit hard to reason about is tr, which is translate.
<baweaver> It basically says take set a and transform it to set b
<baweaver> but that's also super dense
alfiemax has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
this_dude has quit [Ping timeout: 252 seconds]
this_dude has joined #ruby
<this_dude> sorry had to relocate pc
<this_dude> im back lol
<this_dude> so you said use .map .ord and %?
tdy has joined #ruby
tdy1 has joined #ruby
tdy has quit [Ping timeout: 248 seconds]
agent_white has quit [Quit: gnight]
<this_dude> what does string.each_char do?
FredrikThuresson has joined #ruby
white_lilies has quit [Ping timeout: 256 seconds]
FredrikThuresson is now known as FredrikT
alfiemax_ has joined #ruby
ciro has quit [Quit: WeeChat 2.2]
cschneid_ has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
zenspider has quit [Ping timeout: 268 seconds]
cschneid_ has quit [Ping timeout: 248 seconds]
dviola has joined #ruby
alfiemax_ has quit [Ping timeout: 240 seconds]
braincrash has quit [Quit: bye bye]
<al2o3-cr> >> 'qefp_arab tfii yb x jxpqbo lc oryv fk kl qfjb :)'.tr'x-za-w','a-z'
<ruby[bot]> al2o3-cr: # => "this_dude will be a master of ruby in no time :)" (https://eval.in/1044781)
braincrash has joined #ruby
FredrikT has quit [Ping timeout: 252 seconds]
gix has joined #ruby
patr0clus has joined #ruby
tdy1 is now known as tdy
Creatornator has joined #ruby
this_dude has quit [Ping timeout: 252 seconds]
rdavila has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
cschneid_ has joined #ruby
patr0clus has quit [Ping timeout: 265 seconds]
patr0clus has joined #ruby
Caerus has joined #ruby
patr0clus has quit [Client Quit]
patr0clus has joined #ruby
cschneid_ has quit [Remote host closed the connection]
this_dude has joined #ruby
JamJam_kid has joined #ruby
<this_dude> @al2o3-cr
<this_dude> i just saw the code you sent lol
<this_dude> how the hell does that compute xD
patr0clus has quit [Ping timeout: 264 seconds]
patr0clus has joined #ruby
alfiemax has joined #ruby
ltd has quit [Quit: leaving]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kapil___ has quit [Quit: Connection closed for inactivity]
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
tristanp has joined #ruby
<this_dude> ill repeat my question from the other channel..can someone please help me correct the syntax of this line
<this_dude> string.map {|v| ((v.ord)+offset).chr}
<havenwood> this_dude: ''.respond_to? :map #=> false
<this_dude> what
<havenwood> this_dude: String doesn't mixin Enumerable or anything else that defined #map, and it isn't defined on String itself either.
tristanp has quit [Ping timeout: 264 seconds]
<this_dude> i have no idea what that means D:
<havenwood> this_dude: Above I asked an empty string if it responds to #map, and it doesn't.
<this_dude> ohhh sorry forgot to give you the context
<this_dude> this is for an any offset caesar cipher
<this_dude> i will use a gets to ask for the offset
<this_dude> and another to ask for the string
<havenwood> this_dude: It looks like you're calling #map on a String, but String doesn't respond to the #map method because #map isn't defined on String.
<havenwood> "this dude".respond_to? :map #=> false
<this_dude> oh wtf
<this_dude> oh yeah i changed it
<this_dude> srry
<havenwood> "this dude".respond_to? :chars #=> true
<this_dude> hmm
<havenwood> >> 'this_dude'.chars
<this_dude> whats the difference
<ruby[bot]> havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<havenwood> #=> ["t", "h", "i", "s", "_", "d", "u", "d", "e"]
<this_dude> then i will use .chars?
<havenwood> this_dude: In Ruby, different Objects respond to different methods.
<this_dude> so .map is for integers
<this_dude> and .chars is for characters
<havenwood> this_dude: No, map is for things that respond to map. And chars is for things that respond to chars.
<havenwood> [].respond_to? :map #=> true
<havenwood> 42.respond_to? :map #=> false
<this_dude> ive never heard of .chars thats why
<havenwood> this_dude: The `[]` or `42` is the "receiver" of the method call. You call the method on the receiver object.
<this_dude> i didnt even know .map existed until earlier
<havenwood> ?pry
<ruby[bot]> Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
<this_dude> so can I use (string.split).char?
<havenwood> this_dude: In Pry, you can easily check what methods an object respond to. You can do it in irb too, it's just more work.
<this_dude> .map***
<havenwood> 'this_dude'.chars.map(&:upcase) #=> ["T", "H", "I", "S", "_", "D", "U", "D", "E"]
<this_dude> woah
<havenwood> 'this_dude'.chars.class #=> Array
<havenwood> this_dude: Array does respond to #map.
<this_dude> so if i turn it into an array with .char i can then call it with .map
<havenwood> this_dude: yes
<this_dude> ok cool
<this_dude> i cant combine a .char.map with a while can I? since the .map IS the while?
<this_dude> i.e
gigetoo has quit [Ping timeout: 248 seconds]
<baweaver> Qo 0.4.0 has been released. `Any` is now used for wildcard values: https://github.com/baweaver/qo
<this_dude> oh hey weaver
<this_dude> im lost again lmao
<baweaver> shall we lend you a map? :D
<this_dude> i think im confused on how the === works
<this_dude> :(
<this_dude> dont make fun pls
<this_dude> i have 10 days to learn this entire language
<this_dude> im really trying
<baweaver> what about ===?
<baweaver> You won't. Focus on getting a decent foundation instead.
<this_dude> i have to
<this_dude> i have the entrance exams
<this_dude> so anyways===
<this_dude> this statement
<this_dude> if (string[i]).split(" ")===(a..w)
<this_dude> is this even written correctly?
<havenwood> this_dude: Skip === for now. You'll want to learn about it when you start writing your own classes.
<baweaver> yeah, I'd ignore it for now
<this_dude> okay how can I write that normally then?
<baweaver> I sincerely doubt you need to know all of Ruby to pass an exam
<this_dude> for any character from a-w
<this_dude> i gotta be able to code all of the problems they give me
<baweaver> I don't know all of Ruby and I've been doing it for some 6-7 years now
<this_dude> :(
<this_dude> um wow
<this_dude> do you do ruby dev for a living?
<this_dude> ah im getting off track
<havenwood> this_dude: what did you mean by the code above? if any word has a letter from "a" to "w" in it or something else?
<this_dude> in the cipher
<this_dude> im trying to separate it into two statements
<this_dude> letters from a-w
<this_dude> and letters from x-z
<havenwood> x, y and z?
<this_dude> yeah lel
<this_dude> that way i can do (string[i].ord + offset).chr
<this_dude> for a-w
<this_dude> and for x,y,z itll be (string[i].ord-(26-offset)).chr
\void has quit [Quit: So long, and thanks for all the fish.]
<havenwood> this_dude: it seems your on a good track
<havenwood> you're*
<this_dude> can I do that using .char.map?
<havenwood> yes
memo1 has joined #ruby
alex`` has joined #ruby
<this_dude> like so?
<this_dude> string.chars.map {|v| ((v.ord)+offset).chr}
<this_dude> or..
gigetoo has joined #ruby
<this_dude> gonna relocate pc brb
this_dude has quit [Ping timeout: 252 seconds]
moei has joined #ruby
mondz has quit [Read error: Connection reset by peer]
apeiros has quit [Remote host closed the connection]
memo1 has quit [Ping timeout: 240 seconds]
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
chussenot has joined #ruby
this_dude has joined #ruby
<this_dude> ok back
Inline has quit [Quit: Leaving]
dviola has quit [Quit: WeeChat 2.2]
alex`` has quit [Ping timeout: 268 seconds]
<this_dude> im getting a strange error
<this_dude> "string cannot be coerced into integer"
aufi has joined #ruby
<baweaver> you tried to add an int and a string
<baweaver> >> 1 + 's'
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
Xeago has quit [Ping timeout: 248 seconds]
<baweaver> hrm
za1b1tsu has joined #ruby
<this_dude> baweaver
<this_dude> what am i doing wrong here
<baweaver> indent things
<baweaver> it'll save you a lot of sanity later
<this_dude> ok haha
biberu has joined #ruby
<baweaver> Also you don't need while loops
<baweaver> Remember map.
nowhere_man has joined #ruby
<this_dude> how do i set the 'a'..'w' parameter into the map?
bak1an has joined #ruby
<this_dude> or can i leave it as is and just remove the while
<baweaver> Also don't use === for that.
<this_dude> D:
lunarkitty7 has joined #ruby
<baweaver> use this style for range inclusions: (1..10).include?(v)
<this_dude> o.o
<this_dude> let me research the .include function..
<this_dude> brb
Nicmavr has quit [Read error: Connection reset by peer]
<baweaver> 'all the stuff'.chars.map { |c| c ... } # Use this style
<baweaver> Are there only going to be lowercase characters?
Nicmavr has joined #ruby
<this_dude> yes
<this_dude> im trying to understand [00:12] <baweaver> 'all the stuff'.chars.map { |c| c ... } # Use this style
<this_dude> so then would it be
patr0clus has quit [Quit: WeeChat 2.1]
<baweaver> >> offset = 13; ('a'..'z').to_a.rotate(offset)
<ruby[bot]> baweaver: # => ["n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a", "b", "c", "d", "e", "f", "g", ...check link for more (https://eval.in/1044794)
<this_dude> wait wtf thats stupid simple..
<baweaver> >> offset = 13; alpha = ('a'..'z').to_a; alpha.zip(alpha.rotate(offset)).to_h
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> >> offset = 13; alpha = ('a'..'z').to_a; alpha.zip(alpha.rotate(offset)).to_h
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> ...fine fine
<this_dude> what is .to_a.rotate?
<baweaver> => {"a"=>"n", "b"=>"o", ... }
<this_dude> let me rephrase
<this_dude> what is .to_a
<this_dude> i know .to_i and .to_s
<this_dude> never heard if .to_a
<lunarkitty7> to array I believe
<this_dude> is that the same as .split?
<lunarkitty7> no
<baweaver> >> offset = 13; alpha = ('a'..'z').to_a; translation = alpha.zip(alpha.rotate(offset)).to_h; translation.default_proc = proc { |h, k| h[k] = k }; 'the rain in spain'.chars.map { |c| translation[c] }.join
<ruby[bot]> baweaver: # => "gur enva va fcnva" (https://eval.in/1044795)
alem0lars has joined #ruby
<baweaver> >> offset = 3; alpha = ('a'..'z').to_a; translation = alpha.zip(alpha.rotate(offset)).to_h; translation.default_proc = proc { |h, k| h[k] = k }; 'the rain in spain'.chars.map { |c| translation[c] }.join
<ruby[bot]> baweaver: # => "wkh udlq lq vsdlq" (https://eval.in/1044796)
<baweaver> :D
<lunarkitty7> in that case it's converting a range to an array this_dude
<this_dude> o-o
<baweaver> yep
snickers has joined #ruby
<lunarkitty7> oh wow, Array.rotate
<lunarkitty7> didn't know about that
<this_dude> i didnt either..
<this_dude> wtf man
<baweaver> translating and commenting it, one sec.
<this_dude> ok ;-;
<lunarkitty7> wow, that is so different from how I did a one line ROT, really interesting
<baweaver> The only reason I do that one is because variable ROT offset.
<baweaver> otherwise just use tr
<this_dude> idk what you guys are saying smh
<this_dude> im trying to write out the code you just gave me...kinda confusing
<this_dude> .to_h?
<lunarkitty7> >> rot=-> s, k {a,aa,l ='a'.ord,'A'.ord,26;p s=s.split('').map {|x| sh = -> x,a {(((x.ord - a) + k)%l + a).chr}; if (a...a+l).include? x.ord then sh[x,a] elsif (aa...aa+l).include? x.ord then sh[x,aa] end}; s.join('')}; rot['meow', 13]
<ruby[bot]> lunarkitty7: # => ["z", "r", "b", "j"] ...check link for more (https://eval.in/1044797)
<baweaver> to hash
<this_dude> oh idk what that is
<lunarkitty7> hash?
redlegion has quit [Read error: Connection reset by peer]
<this_dude> thats one of the things they said i wouldnt need to know
<this_dude> yeah
<lunarkitty7> it's a key:value store
<baweaver> you know what a dictionary is in real life?
<this_dude> mhm
<baweaver> it has words that have definitions
<baweaver> or rather keys that have values
redlegion has joined #ruby
redlegion has quit [Excess Flood]
<lunarkitty7> Super super super useful
<baweaver> So instead of an array having an index that's a number, it has an index which is anything
moei has quit [Ping timeout: 256 seconds]
redlegion has joined #ruby
<this_dude> so what did you turn into a hash?
<baweaver> :D
<this_dude> i have so many links open from you rn lmao
chussenot has quit [Quit: chussenot]
<baweaver> >> %w(a b c).zip([1,2,3]).to_h
<this_dude> im learning so much im supposed to be ignoring looool
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> danged bot
<baweaver> >> %w(a b c).zip([1,2,3]).to_h
dionysus69 has joined #ruby
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> => {"a"=>1, "b"=>2, "c"=>3}
<this_dude> and this all works in rails?
<baweaver> yep
<baweaver> Rails is just Ruby
<baweaver> well, rather Rails is built in ruby
<this_dude> whats with the .zip
unsymbol has quit []
<baweaver> How does a zipper work in real life?
<this_dude> what did you compress
<this_dude> well ik what a .zip file is
<this_dude> but like
<this_dude> how tf did you just create one mid code
<baweaver> It takes two sides and zips them together
<baweaver> %w(a b c).zip([1,2,3])
<baweaver> => [["a", 1], ["b", 2], ["c", 3]]
<baweaver> So now I took two arrays and zipped them together
<baweaver> by putting to_h on the end I now have a key value instead.
<this_dude> THATS COOL
<this_dude> um
<baweaver> AHA!
alem0lars has quit [Quit: Leaving]
<baweaver> I did get through enough of it
<baweaver> Learn more Ruby
<baweaver> ....with cartoon lemurs
<baweaver> That version isn't done, but it gets enough in there.
<this_dude> lmao
<this_dude> is it necessary?
<this_dude> or can i just read the other links lol
<baweaver> Eh, either or.
<this_dude> btw im still trying to follow the syntax of your code
<baweaver> I just explain more in there.
<this_dude> another question
<lunarkitty7> Oh wow, it's like a toned down Why's Poignant guide!
<lunarkitty7> *bookmarks*
<baweaver> Oh it's about to be toned up
<baweaver> lunarkitty7: How much do you know about what I've been working on?
<lunarkitty7> :p
<lunarkitty7> *looks at chatlog*
<baweaver> One of the more interesting ones recently is that I was speaking at Southeast Ruby
<baweaver> and I illustrated the entire talk
<baweaver> That goes through how I went about it, but the gist of it is 135 hours into it, and it explains how to use reduce effectively.
<lunarkitty7> wow
<baweaver> It's also me getting substantially better at illustration
<this_dude> ok im ready to ask questions
<baweaver> because I happen to have something very interesting that I'm not going to mention on channel :)
<this_dude> .default_proc?
<this_dude> actually this entire line
<this_dude> translation.default_proc = proc { |h,k| h[k] = k}
<baweaver> Heh, yeah, figured that one
<lunarkitty7> awesome baweaver
<baweaver> The talk should be live in 2 weeks or so.
<baweaver> I went full on voice acting for each lemur too
<baweaver> ok, so, default proc
<baweaver> If a key can't be found in a hash, it returns nil by default
arup_r has joined #ruby
<this_dude> wdym
<baweaver> if there's a default proc, it calls that when it finds a key it doesn't know about
<baweaver> >> {a: 1}[:b]
<this_dude> like since the range is a..z and you put 0 it would return nil?
<ruby[bot]> baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver> => nil
tty has quit [Quit: tty]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<baweaver> So if that key isn't in there (:b isn't) it gives nil
<baweaver> In our case we want to not translate any character that's not a lowercase letter.
<this_dude> like since the range is a..z if you put 0 it would return nil?
<baweaver> The simpler idea would instead be: translate[c] || c
<baweaver> except it's a hash after the zip.to_h
apeiros has joined #ruby
<this_dude> also
<this_dude> from this line
apeiros has quit [Read error: Connection reset by peer]
<this_dude> alpha=('a'..'z').to_a.rotate(offset)
<this_dude> to this line
<this_dude> translation=alpha.zip(alpha.rotate(offset)).to_h
<this_dude> you have a double rotation
<this_dude> i dont understand
<baweaver> There we go
<baweaver> >> ALPHABET = ('a'..'z').to_a; offset = 13; translation = ALPHABET.zip(ALPHABET.rotate(offset)).to_h; 'strings are real fun BUT NOT THIS'.chars.map { |c| translation[c] || c }.join
<ruby[bot]> baweaver: # => "fgevatf ner erny sha BUT NOT THIS" (https://eval.in/1044799)
<this_dude> wow
<this_dude> really well notated
<this_dude> what do you do for a living??
<baweaver> Software Engineer
lunarkitty7 has quit [Ping timeout: 256 seconds]
<this_dude> thats what i wanna be D:
<this_dude> um why is alphabet all caps
<this_dude> that sets it to an unalterable item right?
<baweaver> We'd like to think so
<this_dude> ok
<this_dude> cool
<baweaver> (in general I _should_ freeze it)
<baweaver> I also get paid to do bad things to Ruby and teach people
<this_dude> so uh
<this_dude> im more of a blackhat coder than a white hat
<this_dude> any violent coding books you need i got all the links hehe
<baweaver> Do note that'll likely get you in trouble on this channel.
<this_dude> even though like you saw earlier..delving into the darknet has apparently compromised my passwords
<this_dude> oh well i wouldnt do it here obviously
<this_dude> im here for school purposes
<baweaver> In general it's not a good idea to go black hat.
<baweaver> White hat pays better.
<this_dude> its kinda fun though..
<this_dude> really?
<this_dude> i know tons of people who sell cc's and make crazy money
<this_dude> i would love to be a ruby dev
<baweaver> In the bay area a Senior class SecOps engineer is raking in around 150-170k base.
<baweaver> That's not counting stock options
<this_dude> which entails how many years exp?
<baweaver> which can double that easily.
<baweaver> depends on skill, normally around 5
<this_dude> ugh
<this_dude> im 21
<this_dude> i dont have that kinda time on my hands
<this_dude> and im not in school
<this_dude> and cant afford to go to school
<baweaver> If you're 21 you have time.
<this_dude> so like..if i dont try to learn by myself i wont learn
lunarkitty7 has joined #ruby
<baweaver> Who says you need to get a degree?
<this_dude> my friend is a senior network engineer and hes 22
<lunarkitty7> dang internet connection
<this_dude> oh
<this_dude> do you not have a degree?
<baweaver> Levels are inflated.
<baweaver> Only a tangentially related one
<this_dude> he leads a team of network engineers
<baweaver> I went to a super cheap state school no-name
<this_dude> he makes great money for our age
<this_dude> im jealous
<this_dude> but you went to school at least :/
<baweaver> Didn't count for much
<baweaver> Every job I had came from hard won experience and networking.
<lunarkitty7> this_dude: about %50 of devs don't have a degree
<baweaver> One of the strongest principal engineers in our company didn't get a degree
<baweaver> and he absolutely demolishes me
<this_dude> hmm
<baweaver> He's also on this channel
<this_dude> oh nice
<this_dude> okay so basically in the coding industry hardwork==money
<this_dude> and experience
<baweaver> Networking is going to be the big card
<this_dude> btw in your code for the cipher i have another question
<baweaver> Hard work with no connections will nail you
<this_dude> what is p translation_table
<this_dude> D:
<baweaver> puts thing.inspect
<this_dude> p == puts?
<baweaver> nope
<lunarkitty7> print right?
<baweaver> p returns the value, puts returns nil
<this_dude> wtf
<baweaver> It inspects the object instead of calling to_s on it.
<baweaver> That one takes some getting used to.
<this_dude> so could i not replace that with
<lunarkitty7> oh, huh I thought it was an alias for print
<this_dude> return translation_table
<baweaver> p is just outputting it so you can see it
<baweaver> the actual return value is at the end
<this_dude> so i can see what?
<this_dude> the entire table?
tristanp has joined #ruby
<baweaver> yep
* baweaver is back on accordion music Youtube
<this_dude> oh uh
<this_dude> your code returns me an error
arup_r_ has joined #ruby
arup_r_ has quit [Client Quit]
arup_r_ has joined #ruby
<this_dude> I can replace the c in the map statement with v also right?
<baweaver> yep, just replace all the c's
<this_dude> ok
<this_dude> and about that
<this_dude> im unfamiliar with that statment
<this_dude> statement*
arup_r has quit [Ping timeout: 244 seconds]
<this_dude> string.chars.map { |v| translation_table[v] || v } .join
<baweaver> yep
<baweaver> Enjoy accordion tango with me - https://youtu.be/Un9sXWWuChU?t=1m
<this_dude> the only one you taught me is { |v| v ___ }
<baweaver> You could use c instead of v
<baweaver> I just tend to use c for character, v for value, i for index, w for word, etc
<this_dude> oh ok
<this_dude> but that wasnt my question
<baweaver> It's not necessary strictly speaking.
<this_dude> my question is this part
<this_dude> { |v| translation_table[v] || v } <--
<baweaver> Ah.
tristanp has quit [Ping timeout: 256 seconds]
<baweaver> Each character gets translated using the translation map. It has the original alphabet latter as the key, and its translation as the value
moei has joined #ruby
<this_dude> yeah but whats the || v
<this_dude> for
<baweaver> If there is no translation, you get back nil. || is saying or this
<this_dude> so
<baweaver> So: false || 'other value'
<this_dude> like if theres a space?
<baweaver> yep
<this_dude> ohhhh ok
<this_dude> thats super cool
<this_dude> btw im listening to that accordion music
<this_dude> actually really relaxing..
<baweaver> >> [true || true, false || true, false || false, true && true, false && true]
<ruby[bot]> baweaver: # => [true, true, false, true, false] (https://eval.in/1044802)
<baweaver> boolean truth operations
<this_dude> oh wait so youre using it as an or statement
<baweaver> Either there's a translation, or you return the original character
<this_dude> ohhhhhhhhhhhhhhh ok
<this_dude> ok but u
<this_dude> um
<this_dude> tht code returns an error btw
<this_dude> for me at least
<baweaver> Astor Piazolla, master of tango :D
<baweaver> Oh?
yohji has joined #ruby
<baweaver> Ah
<baweaver> Are you passing in a string for the rotation?
<baweaver> gets isn't _that_ smart
<this_dude> i dont understand the question
<baweaver> gets will give you a string
<this_dude> yeah
<baweaver> you have to make that an integer
<baweaver> rotate takes an integer
<this_dude> oh shoot
<this_dude> wellllll uhhhh
arup_r_ has quit [Ping timeout: 256 seconds]
<this_dude> can i just use string=string.to_i
<baweaver> input = gets.chomp; rot = gets.chomp.to_i; cipher(input, rot)
arup_r has joined #ruby
<this_dude> o-o
<this_dude> heres my code...
arup_r has quit [Remote host closed the connection]
<baweaver> chomp gets rid of newlines
<this_dude> yeah ik
<baweaver> yep, use that above
arup_r has joined #ruby
<this_dude> hmm
<this_dude> im getting stuck in a loop now
<this_dude> yeah something is wrong
sysvalve has joined #ruby
alicef has quit [Ping timeout: 240 seconds]
<this_dude> ahhhhh
<this_dude> help
<baweaver> you reversed the arguments.
<baweaver> you're also using gets in the method
<this_dude> wdym i reversed the arguments
<baweaver> I'll let ya figure that one.
alicef has joined #ruby
<this_dude> hmm
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<this_dude> can i do this
<this_dude> string=gets.chomp.to_i
<this_dude> it keeps saying no implicit conversion of string to integer
<this_dude> oh i removed the .to_i from the .char.map
<this_dude> but still getting the same error
ineb has joined #ruby
JamJam_kid has quit [Ping timeout: 256 seconds]
<ineb> if you go the dynamic approach and generate a client api out of the REST specifications
<ineb> would you generate the actual ruby code via erb templates
<ineb> or load the specifications (json) and create the code via meta programming?
<baweaver> Calling it a night. 'cheers
<this_dude> waittttt
<baweaver> Apipie or Swagger
<baweaver> Don't make it complicated.
<this_dude> i have to finish at least this one
<baweaver> You're close, you have to think it through though
<this_dude> me?
<baweaver> mainly what's an offset and what's the string
<baweaver> Anyways, late here and sleep is good.
<this_dude> oh i forgot offset to int?
<this_dude> hmm alright :/ g'night
<this_dude> oh i fixed the integer error and got a new one instead lmao
snickers has joined #ruby
clemens3_ has joined #ruby
apeiros has joined #ruby
mikecmpbll has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ferhaty has joined #ruby
alex`` has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
p4p0l0 has joined #ruby
snickers has joined #ruby
vedu has joined #ruby
WA9ACE has quit []
this_dude has quit [Ping timeout: 252 seconds]
<vedu> Hello. I am unable to get `rake task` working in my project https://github.com/vedant1811/customer-records. Currently it runs with "0 runs, 0 assertions, 0 failures, 0 errors, 0 skips"
mikecmpbll has joined #ruby
Beams has joined #ruby
MuffinPimp has quit [Read error: Connection reset by peer]
MuffinPimp has joined #ruby
drale2k_ has joined #ruby
TomyWork has joined #ruby
arup_r has quit []
sameerynho has joined #ruby
Zaab1t has joined #ruby
amelliaa has joined #ruby
Freshnuts has joined #ruby
Freshnuts has quit [Quit: Leaving]
cabotto has joined #ruby
Freshnuts has joined #ruby
alicef has quit [Ping timeout: 240 seconds]
Mike11 has joined #ruby
alicef has joined #ruby
meinside has quit [Quit: Connection closed for inactivity]
rishibit has joined #ruby
ansraliant has quit [Quit: Konversation terminated!]
dhollin3 has joined #ruby
rishibit has left #ruby [#ruby]
dhollinger has quit [Ping timeout: 240 seconds]
cabotto has quit [Remote host closed the connection]
cabotto has joined #ruby
aufi has quit [Ping timeout: 264 seconds]
User458764 has joined #ruby
User458764 has quit [Client Quit]
cabotto has quit [Ping timeout: 260 seconds]
cabotto has joined #ruby
tdy has quit [Ping timeout: 264 seconds]
morantron has joined #ruby
Caerus has quit [Read error: Connection reset by peer]
<morantron> hi! is there a way to set a breakpoint when a constant in a class is being defined? some gem is defining a constant, and I'm not sure where it comes from...
Caerus has joined #ruby
alfiemax has quit [Remote host closed the connection]
p4p0l0 has quit [Read error: No route to host]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Freshnuts has quit [Quit: Leaving]
<apeiros> morantron: just define it again, ruby will tell you that it already exists and where the original definition was
jp has quit [Ping timeout: 268 seconds]
desperek has joined #ruby
jp has joined #ruby
Dbugger has joined #ruby
drale2k_ has joined #ruby
<dionysus69> return some_var if > 0 would be great syntax, wouldn't it? instead of return some_var if some_var > 0
<dionysus69> I assume it would require one more line in ruby's source code
<apeiros> mid-method returns are the way of the spaghetti
TJ- has joined #ruby
<dionysus69> apeiros: why what's wrong with them? never found anything against guard clause, until now ^.^ rubocop actually tells you to use them in some cases
Bish has joined #ruby
<Bish> does anyone of you guys operate your own DNS server written in ruby?
<apeiros> there's plenty of material online about what's spaghetti code and why it's bad. I suggest you make use of google.
erlend has left #ruby ["WeeChat 1.9.1"]
tdy has joined #ruby
elphe has quit [Ping timeout: 264 seconds]
morantron has quit [Remote host closed the connection]
postmodern has quit [Quit: Leaving]
apparition has joined #ruby
aufi has joined #ruby
FernandoBasso has joined #ruby
dminuoso has joined #ruby
<dminuoso> Given `[:foo, :bar, :quux]` and `:baz` I want to obtain `{ foo: :baz, bar: :baz, quux: :baz}` is there an expressive but compact way to do this?
<dminuoso> >> [:foo, :bar, :quux].map { |e| [e, :baz] }.to_h
<ruby[bot]> dminuoso: # => {:foo=>:baz, :bar=>:baz, :quux=>:baz} (https://eval.in/1044936)
<dminuoso> I dont like this.
<dionysus69> I'd say that's good enough, I just did something like that :D
elphe has joined #ruby
<dminuoso> Ah well screw it. Its not worth the time.
<dionysus69> >> Hash[[:foo, :bar, :quux].collect { |e| [e, :baz] } ]
<ruby[bot]> dionysus69: # => {:foo=>:baz, :bar=>:baz, :quux=>:baz} (https://eval.in/1044941)
<dionysus69> I think the first one is better though
GodFather has quit [Remote host closed the connection]
elphe has quit [Ping timeout: 260 seconds]
tristanp has joined #ruby
elphe has joined #ruby
oldandwise has joined #ruby
tristanp has quit [Ping timeout: 260 seconds]
ArahaelPi has quit [Ping timeout: 240 seconds]
flakas_ has joined #ruby
ciro has joined #ruby
flakas_ has quit [Quit: Leaving]
flakas has joined #ruby
arahael1 has joined #ruby
schneider has joined #ruby
arahael1 has quit [Read error: Connection reset by peer]
Mike11 has quit [Quit: Leaving.]
arahael1 has joined #ruby
AJA4350 has joined #ruby
aufi has quit [Ping timeout: 240 seconds]
schneider has quit [Ping timeout: 240 seconds]
schneider has joined #ruby
elphe has quit [Ping timeout: 240 seconds]
schneider has quit [Quit: WeeChat 2.0.1]
wildermind has joined #ruby
tty has joined #ruby
elphe has joined #ruby
fmcgeough has joined #ruby
fmcgeough has quit [Client Quit]
elphe has quit [Ping timeout: 268 seconds]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 260 seconds]
AJA4351 is now known as AJA4350
AJA4351 has joined #ruby
elphe has joined #ruby
bmurt has joined #ruby
savolla has joined #ruby
AJA4350 has quit [Ping timeout: 260 seconds]
AJA4351 is now known as AJA4350
elphe has quit [Ping timeout: 248 seconds]
Sigyn has quit [Quit: People always have such a hard time believing that robots could do bad things.]
AJA4351 has joined #ruby
Sigyn has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
elphe has joined #ruby
AJA4351 has quit [Ping timeout: 255 seconds]
AJA4350 has joined #ruby
hs366 has joined #ruby
elphe has quit [Ping timeout: 248 seconds]
amelliaa has quit [Quit: -]
AJA4351 has joined #ruby
elphe has joined #ruby
AJA4350 has quit [Ping timeout: 268 seconds]
AJA4351 is now known as AJA4350
elphe has quit [Ping timeout: 244 seconds]
drale2k_ has joined #ruby
InfinityFye has joined #ruby
elphe has joined #ruby
ciro has quit [Ping timeout: 240 seconds]
jcalla has joined #ruby
elphe has quit [Ping timeout: 248 seconds]
elphe has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 244 seconds]
AJA4351 is now known as AJA4350
elphe has quit [Ping timeout: 268 seconds]
cabotto has quit [Remote host closed the connection]
elphe has joined #ruby
cabotto has joined #ruby
fmcgeough has joined #ruby
aufi has joined #ruby
yokel has joined #ruby
elphe has quit [Ping timeout: 240 seconds]
snickers has joined #ruby
aufi has quit [Read error: Connection reset by peer]
aufi has joined #ruby
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Caius has quit [Ping timeout: 244 seconds]
soahccc has quit [Ping timeout: 248 seconds]
Caius has joined #ruby
elphe has joined #ruby
ciro has joined #ruby
gray_-_wolf has joined #ruby
<gray_-_wolf> I want to have "read-only" Struct, I've come up with `Struct.new(:foo, :bar) { members.each { |m| remove_method("#{m}=") } }`, is there a better way?
elphe has quit [Ping timeout: 244 seconds]
<dminuoso> gray_-_wolf: Live with the fact that Ruby has no type system?
<dminuoso> gray_-_wolf: Regardless of what you do, there's enough backdooring to undo what you do.
<dminuoso> gray_-_wolf: If you just want some basic "I dont want to shoot myself" protection, what you wrote is the best you can get.
Inline has joined #ruby
<ineb> wait. just #freeze and/or its members
<ineb> *just #freeze the struct
* dminuoso readies his fiddled thaw method..
amelliaa has joined #ruby
<gray_-_wolf> ineb: heh, that's probably a better way :) didn't think of that
elphe has joined #ruby
<ineb> np :)
snickers has joined #ruby
<havenwood> >> %i[foo bar quux].each_with_object(:baz).to_h
<ruby[bot]> havenwood: # => {:foo=>:baz, :bar=>:baz, :quux=>:baz} (https://eval.in/1045031)
<dminuoso> why..
* dminuoso sighs
<dminuoso> havenwood: This is why I dont like Ruby.
<havenwood> dminuoso: What's wrong with each_with_baz?
<ineb> dminuoso: i dont think its possible to easily unfreeze an object
<havenwood> ineb: dup it
<ineb> maybe with some hacks of the ruby interpreter
elphe has quit [Ping timeout: 248 seconds]
* havenwood mutters something about the 11th bit
snickers has quit [Client Quit]
<dminuoso> havenwood: why would you ever dup over cloning?
<dminuoso> oh well.
<dminuoso> to unfreeze I guess
<dminuoso> heh
<havenwood> The ^
<havenwood> hehe, yup
<dminuoso> havenwood: But seriously, its regarded because it's unclear why that works.
<dminuoso> *retarded
reber has joined #ruby
<dminuoso> I mean the stuff Ruby does to block arity to *implicitly* always somehow fit..
elphe has joined #ruby
GodFather has joined #ruby
gnufied has joined #ruby
keanny479 has joined #ruby
apparition has quit [Quit: Bye]
ciro has quit [Ping timeout: 265 seconds]
elphe has quit [Ping timeout: 268 seconds]
User458764 has joined #ruby
cabotto has quit [Remote host closed the connection]
elphe has joined #ruby
AJA4351 has joined #ruby
cabotto has joined #ruby
cabotto has quit [Client Quit]
memo1 has joined #ruby
<keanny479> hey everyone
AJA4350 has quit [Ping timeout: 265 seconds]
AJA4351 is now known as AJA4350
elphe has quit [Ping timeout: 240 seconds]
<keanny479> which gems do you use for a ruby script ? the purpose of the script is to manage unix daemons (copy configuration file, replace keywords like sed...)
eddof13 has joined #ruby
dminuoso has left #ruby ["WeeChat 2.0.1"]
<keanny479> i found rr, safe_shell interesting
<keanny479> what do you use guys ?
AJA4350 has quit [Ping timeout: 260 seconds]
<darix> i leave managing daemons to my init system
flips_ has joined #ruby
pmarreck_ has joined #ruby
dhollin3 is now known as dhollinger
rjungemann_ has joined #ruby
Kilobyte22 has joined #ruby
jwheare_ has joined #ruby
flakas has quit [Write error: Connection reset by peer]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
spectra has quit [Ping timeout: 240 seconds]
pmarreck has quit [Ping timeout: 240 seconds]
mkaito has quit [Ping timeout: 240 seconds]
jwheare has quit [Ping timeout: 240 seconds]
rjungemann has quit [Ping timeout: 240 seconds]
justache has quit [Ping timeout: 240 seconds]
flips has quit [Ping timeout: 240 seconds]
Mutsuhito has quit [Ping timeout: 240 seconds]
swein has quit [Ping timeout: 240 seconds]
vircung has quit [Ping timeout: 240 seconds]
vermaneerajin[m] has quit [Ping timeout: 240 seconds]
legion[m] has quit [Ping timeout: 240 seconds]
eregon has quit [Ping timeout: 240 seconds]
Biohazard has quit [Ping timeout: 240 seconds]
snapcase has quit [Ping timeout: 240 seconds]
bier has quit [Ping timeout: 240 seconds]
epochwolf has quit [Ping timeout: 240 seconds]
dan64 has quit [Ping timeout: 240 seconds]
noizex has quit [Ping timeout: 240 seconds]
Kilo`byte has quit [Ping timeout: 240 seconds]
Evesy has quit [Ping timeout: 240 seconds]
rjungemann_ is now known as rjungemann
flips_ is now known as flips
pmarreck_ is now known as pmarreck
jwheare_ is now known as jwheare
<havenwood> keanny479: I'd suggest considering Open3 in the stdlib: https://docs.ruby-lang.org/en/trunk/Open3.html
dan64 has joined #ruby
AJA4350 has joined #ruby
vircung has joined #ruby
helpa has quit [Ping timeout: 260 seconds]
sagax has joined #ruby
Mutsuhito has joined #ruby
elphe has joined #ruby
za1b1tsu has quit [Ping timeout: 260 seconds]
ferhaty has quit [Quit: ferhaty]
biberu has quit []
Guest26876 has joined #ruby
spectra has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elphe has quit [Ping timeout: 240 seconds]
<apeiros> darix: ! nice
<apeiros> darix: I guess I'll have to stop my manga rampage and use that time more wisely - like with that bundle :D
Guest26876 is now known as giraffe
apeiros has quit []
Burgestrand has joined #ruby
dionysus69 has quit [Ping timeout: 260 seconds]
johnny56_ has quit [Ping timeout: 276 seconds]
johnny56 has joined #ruby
desperek has quit [Ping timeout: 260 seconds]
elphe has joined #ruby
savolla has quit [Ping timeout: 240 seconds]
ciro has joined #ruby
k0mpa has joined #ruby
elphe has quit [Ping timeout: 264 seconds]
Neptu_ is now known as Neptu
chouhoulis has joined #ruby
tdy has quit [Ping timeout: 244 seconds]
Morrolan has quit [Quit: Goodbye]
Morrolan has joined #ruby
Creatornator has joined #ruby
tdy has joined #ruby
Morrolan has quit [Client Quit]
Morrolan has joined #ruby
AJA4350 has quit [Ping timeout: 264 seconds]
Burgestrand has quit [Quit: Closing time!]
mostlybadfly has joined #ruby
elphe has joined #ruby
Morrolan has left #ruby ["WeeChat 2.2"]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troys has joined #ruby
Inline has quit [Read error: Network is unreachable]
elphe has quit [Ping timeout: 240 seconds]
Inline has joined #ruby
k0mpa has quit [Quit: k0mpa]
snickers has joined #ruby
morantron has joined #ruby
alfiemax has joined #ruby
johnny56 has quit [Ping timeout: 276 seconds]
elphe has joined #ruby
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mikecmpb_ has joined #ruby
mikecmpbll has quit [Ping timeout: 265 seconds]
elphe has quit [Ping timeout: 240 seconds]
orbyt_ has joined #ruby
dionysus69 has joined #ruby
orbyt_ has quit [Client Quit]
apeiros_ has joined #ruby
za1b1tsu has joined #ruby
Mike11 has joined #ruby
elphe has joined #ruby
cagomez has joined #ruby
Creatornator has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
za1b1tsu has quit [Ping timeout: 264 seconds]
elphe has quit [Ping timeout: 248 seconds]
morantron has quit [Remote host closed the connection]
WA9ACE has joined #ruby
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lightstalker has quit [Ping timeout: 248 seconds]
kapil___ has joined #ruby
Creatornator has joined #ruby
lightstalker has joined #ruby
Beams has quit [Quit: .]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elphe has joined #ruby
drale2k_ has joined #ruby
lightstalker has quit [Ping timeout: 240 seconds]
sysvalve has quit [Quit: Leaving]
elphe has quit [Ping timeout: 244 seconds]
jjman has left #ruby ["WeeChat 1.6"]
banisterfiend has joined #ruby
lightstalker has joined #ruby
jp has joined #ruby
elphe has joined #ruby
clemens3_ has quit [Remote host closed the connection]
elphe has quit [Ping timeout: 240 seconds]
dionysus69 has quit [Ping timeout: 240 seconds]
amelliaa has quit [Quit: -]
aufi has quit [Ping timeout: 265 seconds]
TomyWork has quit [Ping timeout: 240 seconds]
qolq has joined #ruby
GodFather has quit [Ping timeout: 245 seconds]
yohji has quit [Remote host closed the connection]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<keanny479> thanks havenwood
cagomez has quit [Remote host closed the connection]
cagomez has joined #ruby
<mensvaga> !paste
elphe has joined #ruby
<gray_-_wolf> is there global variable for value case is being matched for? atm I have `case (v = a.b.c.d.foo()); when 'a'; when 'b'; else puts "Unknown #{v}"; end`... is there a global variable like there are for regular expressions I could use to not need the `v` variable?
keanny479 has quit [Ping timeout: 252 seconds]
elphe has quit [Ping timeout: 240 seconds]
orbyt_ has joined #ruby
flakas has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
white_lilies has joined #ruby
<apeiros_> gray_-_wolf: no. if you need that, assign before the case statement.
<apeiros_> not all your code needs to fit on a single line.
apeiros_ is now known as apeiros
mikecmpb_ has quit [Quit: inabit. zz.]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gray_-_wolf> shame :/
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Nicmavr has quit [Read error: Connection reset by peer]
cagomez has quit [Remote host closed the connection]
Nicmavr has joined #ruby
elphe has joined #ruby
cagomez has joined #ruby
za1b1tsu has joined #ruby
desperek has joined #ruby
flakas_ has joined #ruby
cagomez has quit [Remote host closed the connection]
flakas has quit [Ping timeout: 260 seconds]
elphe has quit [Ping timeout: 244 seconds]
za1b1tsu has quit [Ping timeout: 256 seconds]
elphe has joined #ruby
cagomez has joined #ruby
eckhardt_ has joined #ruby
banisterfiend has joined #ruby
alex`` has quit [Ping timeout: 240 seconds]
mostlybadfly has quit [Quit: Connection closed for inactivity]
Creatornator has joined #ruby
segy has quit [Ping timeout: 260 seconds]
patr0clus has joined #ruby
r29v has joined #ruby
justache has joined #ruby
jrich523 has joined #ruby
memo1 has quit [Ping timeout: 256 seconds]
segy has joined #ruby
noobineer has joined #ruby
snickers has joined #ruby
Demos_ has joined #ruby
Zaab1t has quit [Quit: Zaab1t]
banisterfiend has quit [Quit: Textual IRC Client: www.textualapp.com]
mikecmpbll has joined #ruby
agent_white has joined #ruby
johnny56 has joined #ruby
bak1an has joined #ruby
Puffball_ has joined #ruby
sticaz has quit [Quit: My name Heff]
maryo has joined #ruby
noobineer has quit [Ping timeout: 256 seconds]
Puffball has quit [Ping timeout: 264 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sticaz has joined #ruby
surrounder has joined #ruby
alex`` has joined #ruby
Mike11 has quit [Quit: Leaving.]
white_lilies has quit [Ping timeout: 260 seconds]
alex`` has quit [Ping timeout: 240 seconds]
jackrandom has quit [Quit: ZNC - https://znc.in]
k0mpa has joined #ruby
jackrandom has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
InfinityFye has quit [Quit: Leaving]
n3b has quit [Ping timeout: 240 seconds]
scrptktty has joined #ruby
za1b1tsu has joined #ruby
jimeh has quit [Read error: Connection reset by peer]
jimeh has joined #ruby
dionysus69 has joined #ruby
k0mpa has quit [Remote host closed the connection]
sticaz has quit [Quit: My name Heff]
alex`` has joined #ruby
sticaz has joined #ruby
crankharder has joined #ruby
drale2k_ has joined #ruby
elphe has quit [Quit: leaving]
augcesar has joined #ruby
alex`` has quit [Ping timeout: 240 seconds]
maryo has quit [Ping timeout: 268 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
Cybergeek has quit [Ping timeout: 276 seconds]
FernandoBasso has quit [Quit: Page closed]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
akaiiro has joined #ruby
SuperLag has quit [Remote host closed the connection]
devlaf has left #ruby [#ruby]
[Butch] has joined #ruby
SuperLag has joined #ruby
wilbert has joined #ruby
GodFather has joined #ruby
alex`` has joined #ruby
reber__ has joined #ruby
white_lilies has joined #ruby
flakas_ has quit [Quit: Leaving]
za1b1tsu has quit [Ping timeout: 264 seconds]
white_lilies has quit [Ping timeout: 240 seconds]
Creatornator has joined #ruby
mochiyoda has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
flakas has joined #ruby
drale2k_ has joined #ruby
white_lilies has joined #ruby
lomex has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
drale2k_ has quit [Client Quit]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drale2k_ has joined #ruby
Creatornator has joined #ruby
memo1 has joined #ruby
Cork has quit [Ping timeout: 240 seconds]
KeyJoo has joined #ruby
patr0clus has quit [Quit: WeeChat 2.1]
gigetoo has quit [Ping timeout: 240 seconds]
wildermind has quit [Quit: Connection closed for inactivity]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lomex has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
agent_white has quit [Remote host closed the connection]
agent_white has joined #ruby
alfiemax has quit [Remote host closed the connection]
dionysus69 has quit [Ping timeout: 256 seconds]
ixti has joined #ruby
klaas has quit [Quit: ZNC - http://znc.sourceforge.net]
drale2k_ has joined #ruby
reber has quit [Remote host closed the connection]
reber__ has quit [Read error: Connection reset by peer]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fmcgeough has joined #ruby
akaiiro has quit [Remote host closed the connection]
akaiiro has joined #ruby
johnny56 has quit [Ping timeout: 276 seconds]
Dbugger has quit [Remote host closed the connection]
r3m has quit [Ping timeout: 260 seconds]
postmodern has joined #ruby
flakas has quit [Read error: Connection reset by peer]
fmcgeough has quit [Quit: fmcgeough]
patr0clus has joined #ruby
KeyJoo has quit [Quit: KeyJoo]
memo1 has quit [Ping timeout: 260 seconds]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alfiemax has joined #ruby
johnny56 has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
siaw23 has joined #ruby
<siaw23> hi i have this simple thing i don’t understand https://gist.github.com/siaw23/3e1e9188c7b464d7370cf31f48b799f4
<siaw23> please check my line 6 comment
GodFather has quit [Ping timeout: 240 seconds]
GodFather has joined #ruby
memo1 has joined #ruby
<elomatreb> siaw23: There must be something missing, you should probably show your entire code
<siaw23> elomatreb that’s my entire code
<siaw23> elomatreb: that’s my entire code
evdubs has joined #ruby
<elomatreb> In that case what do you mean by getting string?
<siaw23> the value from the first line `string = gets.chomp`
GodFather has quit [Ping timeout: 244 seconds]
<siaw23> so whatever i type in the terminal when i run this i get it back instead of []
<siaw23> i’m trying to get [] if the lenth of whatever i type is not 1
<elomatreb> By get you mean print to the terminal in this case, or return from a method?
evdubs has quit [Client Quit]
Caerus has quit [Ping timeout: 256 seconds]
<apeiros> can't be the whole code. toplevel return raises "in `<main>': unexpected return (LocalJumpError)"
<siaw23> both, return and print to the terminal
<elomatreb> apeiros: It doesn't (although I'm not quite sure why..)
<siaw23> apeiros: it doesn't
<apeiros> I ran this code and it does if I type e.g. "hi\n"
<apeiros> so not quite sure how you folks run this code…
<siaw23> wow this is very weird
<siaw23> i ran it by doing
<siaw23> ruby lab.rb
<siaw23> lab.rb has the code in the gist
<siaw23> nothing more nothing less
<apeiros> hm, interesting. `ruby` and then running the code is different from running it as a file (running it as a file didn't raise)
<elomatreb> Anyway, if you want something to be printed you will need some method that actually prints
evdubs has joined #ruby
<elomatreb> E.g. in your code, the upper branch uses puts for this
<apeiros> ok. as of ruby 2.4+, toplevel return *in a file* no longer raises.
<apeiros> interesting.
<siaw23> elomatreb: i can’t do `puts Array.new`
<siaw23> yeah so this confuses the hell out of me!
<elomatreb> siaw23: Depending on what you want, you can use the debug output, `puts Array.new.inspect` (or just `p Array.new`)
lunarkitty7 has quit [Ping timeout: 256 seconds]
<siaw23> elomatreb: OK so i think just leaving it as `Array.new` works becaues it actually returns []
thy0 has joined #ruby
<elomatreb> Yes, Ruby always returns the last evaluated expression from a block. This is why an explicit return is often only necessary if you want to abort early
mikecmpbll has joined #ruby
memo1 has quit [Ping timeout: 268 seconds]
alex`` has quit [Ping timeout: 248 seconds]
[Butch] has quit [Quit: Textual IRC Client: www.textualapp.com]
wilbert has quit [Ping timeout: 260 seconds]
thy0 has quit [Client Quit]
thy0 has joined #ruby
lunarkitty7 has joined #ruby
white_lilies has quit [Ping timeout: 260 seconds]
<siaw23> thanks ;)
Creatornator has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has joined #ruby
desperek has quit [Quit: xoxo]
this_dude has joined #ruby
memo1 has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
chouhoulis has quit [Ping timeout: 240 seconds]
Caerus has joined #ruby
scrptktty has quit [Quit: Connection closed for inactivity]
siaw23 has quit [Quit: siaw23]
siaw23 has joined #ruby
r3m has joined #ruby
joast has quit [Quit: Leaving.]
zapata has quit [Quit: WeeChat 2.2]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
siaw23 has quit [Quit: siaw23]
mondz has joined #ruby
zapata has joined #ruby
siaw23 has joined #ruby
alfiemax has joined #ruby
eckhardt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
apeiros has quit []
joast has joined #ruby
<SuperLag> assureone_packages.grep(/AssureNow4-Cumulative\d{2}.zip$/).max(2).min <-- what does the ".max(2).min" part do?
alfiemax has quit [Ping timeout: 256 seconds]
<SuperLag> I read that, so far, as "from all the values in var assureone_packages, match on AssureNow4-Cumulative(with any two digits).zip" then I'm lost at what the max & min part does.
siaw23 has quit [Quit: siaw23]
eckhardt_ has joined #ruby
white_lilies has joined #ruby
joast has quit [Quit: Leaving.]
<TJ-> SuperLag: Enumerable.max(2) will return the two largest values. .min will then return the lowest of those
<this_dude> wait
<this_dude> so
<this_dude> im writing a method right now that returns the 3 largest numbers in a string of numbers
<this_dude> can i use that to do so?
<this_dude> ty
augcesar has quit [Quit: Connection closed for inactivity]
<this_dude> wow so
<this_dude> string.max(3)
<this_dude> ?
<SuperLag> TJ-: same here. Thank you, and that very much.
joast has joined #ruby
<this_dude> superlag
sameerynho has quit [Ping timeout: 244 seconds]
siaw23 has joined #ruby
<TJ-> I just read the docs! I'm new to Ruby, only been hacking on it for a week (adding functions to vagrant-{libvirt,mutate} )
<SuperLag> this_dude: it's not that I'm writing a method. I'm reading someone else's code.
p4p0l0 has joined #ruby
<SuperLag> this_dude: I understood it up to that point (that's why I wrote it out)
<this_dude> oh wait i just reread the problem im doing
<this_dude> i have to return the 3rd greatest value only
<this_dude> not the 3 greatest
<this_dude> any idea how to do so simply?
<SuperLag> then I'm guessing it'd be .max(3).min
<this_dude> so simple
<SuperLag> i.e. get the minimum of the top three values
<this_dude> yep
<SuperLag> read it out load to yourself... it helps me
<SuperLag> rubber duck debugging
<this_dude> oh following the syntax its hard to me haha
<this_dude> its figuring it out from scratch haha
<SuperLag> I'm reading something I inherited to work on. I understand ~60% of it.
<this_dude> wow that literally worked
<this_dude> ...
<this_dude> def third_greatest(nums) nums.max(3).min end
<SuperLag> let me introduce you to something else awesome for ruby.... it's called pry
<SuperLag> gem install pry
<TJ-> you should have had my problem last week
<SuperLag> use pry like you would irb
<SuperLag> TJ-: him, or me?
<Caerus> and thus, you see why we´re doing ruby :)
<Caerus> welcome
<TJ-> Simulating static local variables in methods!
<this_dude> this is the answer they gave lmao
<this_dude> vs my answer above^
<this_dude> pry?
<SuperLag> whoa, that's a lot of code
<SuperLag> (for that problem)
<this_dude> exactly lmfao
<SuperLag> however... when you aren't familar with $METHOD... it's understandable
<this_dude> thats why i thought it was ridiculous
<this_dude> that i could do it in one line
<this_dude> $method?
<SuperLag> or... sorry, maybe $CLASS is the better term to use here
<this_dude> so basically im studying for basic entrance exams for rubyonrails
siaw23 has quit [Quit: siaw23]
ianbrown78 has joined #ruby
<this_dude> and theres sooooo much that they said you "didnt need to know" for the exams
<SuperLag> like I wasn't familiar with the Enumerable thing
<this_dude> but this is like the 5th problem that i can code in one line lmfao
<this_dude> vs the massive amount of code they provide as the answer
<SuperLag> entrance exams on what?
<SuperLag> or for what
<this_dude> AppAcademy
<TJ-> this_dude: maybe the intent is or you to come up with an algorithm to do it yourself?
<SuperLag> ^^^^
<SuperLag> when you don't know about all the options available to you, sometimes the hardest way *is* THE WAY
<this_dude> well so this is what they said
<SuperLag> pay your dues by figuring it out the hard way first... then after you've grown your skills some... okay, here's this MUCH easier way to do it
<this_dude> but like...everything in that list makes your life 10000000% easier
<this_dude> thats what i always hated about school
<Caerus> makes sense, specially if the program is suited for someone that is just comming into programming
<SuperLag> you just want the calculator up front
<this_dude> i have the intellect to understand the easier ways from the gitgo but they always made me go at everyone else's pace
<SuperLag> pay your dues, dude :)
<this_dude> for example i needed to code a method that takes a string and capitalizes the first letter of each word in the string
<this_dude> and opposed to their massive code block i did it in one line..again
<SuperLag> or... maybe they want to know... Can you find out about Enumerable, and how to do it with that?
<SuperLag> with no help from IRC or anyone else, just pure research skills on your part
<this_dude> i think im supposed to do self research and blow them away or something
<this_dude> idk
<this_dude> but i have 2 exams to take on hacker rank in the next few days
<this_dude> so lets see how i do
<SuperLag> I bombed my first try at HR.
<this_dude> uhoh
<this_dude> tell me about it
<this_dude> btw that capitalize method i did like this lo
<this_dude> lol*
<this_dude> string.split(" ").map{ |v| v.capitalize}.join(" ")
<this_dude> literally one line
<Caerus> well. you could argue that knowing the ´procedural´ way of acomplishing some task makes it so you can appreate the elegance that ruby and it´s core libs provide.
<SuperLag> It was hard. Over my head. I wasn't ready.
<this_dude> D:
<this_dude> dont tell me thatttttt
<Caerus> its*
<this_dude> I only have to code midlevel programs according to the email i got
<this_dude> such as the capitalize one i just described
<SuperLag> this_dude: ever heard of Chef?
<this_dude> from ifunny lol?
<SuperLag> no
<SuperLag> as in the Ruby DSL for automating "infrastructure as code"
<SuperLag> like Puppet, like Ansible
<SuperLag> (and others)
<SuperLag> but those are The Big Three for automation
<this_dude> never heard of em
<SuperLag> Chef development has literally been *my INTRODUCTION* to code, past anything other than bash and perl stuff for sysadmin work
<this_dude> <Caerus> well. you could argue that knowing the ´procedural´ way of acomplishing some task makes it so you can appreate the elegance that ruby and it´s core libs provide.
<this_dude> ^ in response to this
<TJ-> this_dude: orchestration and configuration management tools
<this_dude> its because the idea is that they're making it so people who have never coded can get into the program
<SuperLag> this_dude: and even though I couldn't pass the HR exam, I'm self-employed doing automation work, and doing *very* well for myself.
<this_dude> but what i dont get is...those people are already at a disadvantage because the way HackerRank works is it ranks you based off points scored in the exams..
<TJ-> this_dude: sounds like it's 2 things: teaching programming, and teaching Ruby
<this_dude> ^ exactly
<SuperLag> this_dude: I am working to improve my skills, and the more I learn of Ruby, the easier Chef becomes.
<Caerus> this_dude, I did mention that in the previous comment :)
siaw23 has joined #ruby
<this_dude> didnt see that srry
<SuperLag> Caerus: that's better worded than I would have come up with
<SuperLag> this_dude: if you don't make the grade with the HR exam, just keep working at it
<this_dude> but yeah i wanna learn the easier ways to do these things considering I already have the coding background for the most part
<this_dude> but...
<this_dude> the HR exams are my key to my futureee
wilbert has joined #ruby
<this_dude> if i dont pass i dont get accepted
<SuperLag> BS.
<this_dude> and then i dont get to go to school for free
<this_dude> and my dreams are deeeed
<this_dude> DED dead
<SuperLag> why? who says you need school?
<this_dude> I wouldnt know what else to do to make money off of coding
<SuperLag> I went to school. Had zero to do with programming, yet I'm making a living doing just that (imperfectly, I might add!).
<this_dude> AppAcademy sets its graduates up with jobs
<SuperLag> <puke>
<this_dude> ):
<SuperLag> sorry, that's a good line
<SuperLag> nobody can guarantee you a job
<this_dude> let me rephrase
<TJ-> Find an open-source project you like, hack on it, contribute code. You'll both learn and be able to point to it as evidence of skill - I'd always take that over some artificial 'exam'
<this_dude> thats how they get their tuition reimbursed
<this_dude> they dont charge tuition until you get a job
eckhardt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<this_dude> so they try their damndest to get you a job
<SuperLag> all this time you're spending on trying to get in... you could be spending learning, and you'd be closer to paying gigs. You don't need school to do it.
<this_dude> well uh
<this_dude> "all this time"
<SuperLag> If there's anything that I've learned over the past 3+ years of doing this... it's that the best way to learn to code... is TO CODE.
<this_dude> i was given 10 days to learn ruby enough to pass the exams
<TJ-> ^^
<this_dude> im on day 5
<SuperLag> read. experiment. break things. figure out how to fix things.
<SuperLag> lather. rinse. repeat.
siaw23 has quit [Client Quit]
<SuperLag> Do it crappy OVER and OVER and OVER AGAIN, until eventually you get good at it.
<SuperLag> this_dude: Very good. Don't stop.
<TJ-> I've found ruby to be a mess, feels like ver sloppy thinking/organisation in many areas. Things like multiple syntaxes for the same code
siaw23 has joined #ruby
<SuperLag> TJ-: I think many of 'em have many ways to do the same thing
<TJ-> I mean being able to optionally drop syntax
<havenwood> TJ-: In Ruby TIMTOWTDI.
<TJ-> It's almost worse than python making invisible whitespace syntactially significant
<TJ-> havenwood: right... no engineering discipline
<havenwood> TJ-: Or rather, optimized for humans.
<this_dude> I wanna learn python
<this_dude> i have multiple books on violent python i need to study
<TJ-> havenwood: one man's expressiveness, is another man's confusion
<this_dude> got them off the darkweb hehehe
<havenwood> TJ-: You can remove more than one way to do it syntax from English, and give that a try. It's overly strict and targeted at new speakers only.
<SuperLag> this_dude: that is from my invoicing system, so it doesn't reflect all my expenses. it's taken me A. LONG. TIME. to get to this point... but full-time in code every single day? That's been about 3 years.
<this_dude> oh hey havenwood
<this_dude> i pm'd you hehehe
<havenwood> TJ-: It ends up that it's more important to be expressive than to only have one way.
<havenwood> TJ-: If you prefer one way, you can choose a lang that constrains you in that way!
<SuperLag> this_dude: there's so much good stuff on Python *FOR FREE* that you don't need to steal anything.
<SuperLag> this_dude: did you look at that screenshot I linked to?
<this_dude> yeah holy cow
<SuperLag> $100/hr.
<SuperLag> and that's *LOW*
<this_dude> WHAT
<havenwood> TJ-: IIR Larry Wall had some interesting things to say about how we gravely err if we target languages at new speakers only.
<this_dude> HOW
<TJ-> havenwood: that isn't my point; having multiple ways to do the same thing is a recipe for confusion and arguments especially in teams
wilbert has quit [Quit: wilbert]
<this_dude> minimum wage in my town is 7.25.
<SuperLag> this_dude: blood. sweat. tears. hard f'n work.
<havenwood> TJ-: When the team isn't fluent in the language, that's definitely true.
<this_dude> i'd be happy making 20/hour :'(
<havenwood> TJ-: If you're looking for a language that best suits amateurs, an essential would be only way way to do anything.
<SuperLag> this_dude: if you're programming, and experienced at it.... I'd say $40-50/hr is THE FLOOR, for in the US
<TJ-> havenwood: I'm only touching ruby to fix programs that are missing functionality; I woulndn't choose to use it for anything serious
<SuperLag> this_dude: but listen... I'm *not* an employee. I'm self-employed. I pay all the taxes and insurance and expenses out of that rate.\
<havenwood> TJ-: I think that''s one reason Python is a great teaching lang.
<SuperLag> this_dude: it's not even close to the same
<SuperLag> havenwood: does it have fewer ways to do things? is that part of the reason why you say that?
<havenwood> SuperLag: Yup.
<havenwood> SuperLag: I prefer Ruby aesthetically.
<havenwood> TJ-: Being able to express more with less ends up being incredibly valuable. We've built tons of *serious* things in Ruby.
Creatornator has joined #ruby
<havenwood> I guess I don't know how serious we're talking. ;-P
<this_dude> LOL *serious*
<this_dude> i like the way you expressed that
memo1 has quit [Ping timeout: 260 seconds]
<havenwood> I forget the interview where Wall said Perl 6 was designed to be used by artificial intelligence programmers. Hehe
<havenwood> I mean artificial intelligence itself being the one programming.