<IGnorAND>
I have a weird hash though: {"node"=>"my_node", "mem"=>65118486528, "cpu"=>0.0878811061129038, "maxcpu"=>16, "id"=>"node/my_node", "status"=>"online", "type"=>"node", "level"=>"", "maxmem"=>84452896768, "disk"=>4445147136, "uptime"=>27682668, "maxdisk"=>38836535296, "ssl_fingerprint"=>"0E:C1:C1:ED:54:33:CD:8D:D0:31:FF:42:DF:21:8A:4D:9E:CB:1D:22:FE:CD:4C:E9:F7:77:0B:EB:60:5E:A5:83"}
darix has quit [Quit: brb]
ramfjord has joined #ruby
renich has joined #ruby
darix has joined #ruby
ramfjord has quit [Ping timeout: 245 seconds]
cliluw has joined #ruby
code_zombie has quit [Quit: Leaving]
mostlybadfly has joined #ruby
laaron has quit [Remote host closed the connection]
fphilipe has joined #ruby
pupsikov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
laaron has joined #ruby
fphilipe has quit [Ping timeout: 276 seconds]
Swyper has quit [Remote host closed the connection]
<comet23>
i have a hard time understanding recursion
arescorpio has joined #ruby
pupsikov has joined #ruby
houhoulis has joined #ruby
ElF3rn4 has joined #ruby
sameerynho has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 255 seconds]
<havenwood>
IGnorAND: **opts is for keyword arguments, like: Node.new(maxcpu: 42)
<havenwood>
IGnorAND: @cpu = opts[:cpu]
<havenwood>
IGnorAND: Alternatively, use actual keyword arguments: def initialize(cpu: nil, level: nil)
<havenwood>
comet23: keep thinking about it in a loop, each loop thinking a bit more, until you reach and understanding, and at that point break out of the loop with your newfound knowledge
<havenwood>
an understanding*
<havenwood>
i guess i should say call your understanding function, passing in the incremental knowledge >.>
jenrzzz has joined #ruby
<elomatreb>
to understand recursion, start by understanding recursion
<havenwood>
but then stop at some point once you understand it
<havenwood>
or it's just an infinite loop
tpanarch1st has quit [Quit: Thanks for your help, nice to see you, take care.]
tdy1 has joined #ruby
gnufied has quit [Remote host closed the connection]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 258 seconds]
tpanarch1st has joined #ruby
ElF3rn4 has quit [Quit: WeeChat 2.4]
duderonomy has joined #ruby
dar123 has joined #ruby
<quarters>
hello. I was wondering if there's a way to get [1,2,3,3,5] from removing [1,2,4] from [1,1,2,2,4,3,3,5] with a single operator. Diff unfortunately removes all instances of the elements [1,2,4] found in the other array
braincrash has quit [Quit: bye bye]
s3nd1v0g1us has quit [Ping timeout: 276 seconds]
dar123 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has joined #ruby
ramfjord has joined #ruby
cranq has quit [Ping timeout: 246 seconds]
cranq has joined #ruby
ramfjord has quit [Ping timeout: 258 seconds]
advorak has joined #ruby
advorak has quit [Client Quit]
duderono_ has joined #ruby
duderonomy has quit [Ping timeout: 276 seconds]
nadir has quit [Quit: Connection closed for inactivity]
pupsikov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dar123 has joined #ruby
podlech has joined #ruby
podlech has quit [Client Quit]
fphilipe has joined #ruby
podlech has joined #ruby
gix- has joined #ruby
gix has quit [Disconnected by services]
pupsikov has joined #ruby
duderono_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fphilipe has quit [Ping timeout: 250 seconds]
arescorpio has quit [Quit: Leaving.]
dar123 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pupsikov has quit [Client Quit]
sauvin has joined #ruby
segy has quit [Ping timeout: 268 seconds]
segy has joined #ruby
Swyper has joined #ruby
mostlybadfly has quit [Quit: Connection closed for inactivity]
weteamsteve1 has quit [Read error: Connection reset by peer]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
fphilipe has joined #ruby
noodle has joined #ruby
reber has joined #ruby
fphilipe has quit [Ping timeout: 276 seconds]
sagax has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
laaron has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
laaron has joined #ruby
comet23 has quit [Quit: Connection closed for inactivity]
podlech has quit [Quit: WeeChat 2.5-dev]
segy has quit [Ping timeout: 258 seconds]
duderonomy has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 258 seconds]
<Swyper>
phaul: thanks xD I'm just a second year comp sci student taking a free online bootcamp to learn some skills
hightower2 has quit [Ping timeout: 258 seconds]
hightower2 has joined #ruby
<havenwood>
quarters: hi! no, there's not a single operator to do just that.
<quarters>
havenwood, thank you
<havenwood>
&>> [1,2,4].each_with_object([1,1,2,2,4,3,3,5]) { |n, a| a.delete_at a.index n }
<adam12>
thadtheman: There's better ways to do it tho. I'd suggest avoiding the class variables in favour of class instance variables (single @). They're more commonly used in Ruby and I act a bit more similar to what you might be used to (imho).
prestorium has quit [Ping timeout: 250 seconds]
fphilipe has quit [Ping timeout: 276 seconds]
jefffrails35 has joined #ruby
dar123 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
jenrzzz has quit [Ping timeout: 250 seconds]
dsmythe has joined #ruby
renich has quit [Ping timeout: 246 seconds]
fphilipe has joined #ruby
hightower3 has joined #ruby
dsmythe has quit [Ping timeout: 264 seconds]
hightower2 has quit [Ping timeout: 258 seconds]
<thadtheman>
havenwood: I'll look closer at Singleton. but at first blush it looks like overkill. Basically what I am doing is simple enough. Test if @@name exists. If it does return it if it doesn't then initialize it and return the value. So what I really need is a way to test if a class variable is initialized.
<havenwood>
thadtheman: Class variables are a thing that Matz wishes he hadn't added to Ruby. They exist for backwards compatibility. Use instance variables.
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
shah^ has joined #ruby
Swyper has quit [Remote host closed the connection]
def_jam is now known as eblip
Swyper has joined #ruby
<phaul>
Swyper: I didn't mean you, or anybody specifically. I have a thing against *some* courses, teaching online or otherwise is a humble thing, earning mony for it is OK. Creating expensive courses with a curriculum that you know, is impossible to teach in the timeframe, but still ask for money for the course is what I was speaking about. Not you.
<Swyper>
oh okay, well if it helps this is a top bootcamp that made all their course material available online for free xD
<Swyper>
phaul, how do you think I should learn or do you have a course you recommend ?
<uplime>
havenwood: if you did want to share data across all instances of a class, how would you do that?
<phaul>
what you are doing is good, at least for a while. Then when you are compfortable with Ruby, my personal recomendation: do a bunch of !hunders! codewars challanges in Ruby. Compare your sollution to the top voted ones once you complete a task
Swyper has quit [Remote host closed the connection]
eb0t_ is now known as eb0t
fphilipe has quit [Ping timeout: 258 seconds]
s3nd1v0g1us has joined #ruby
s3nd1v0g1us has quit [Quit: WeeChat 2.4]
<phaul>
&>> class C; class << self; attr_accessor :foo; end; def blah; self.class.foo ; end end; x = C.new; C.foo = 13; x.blah # uplime
<Swyper>
im confused as to why in pry it seems what I am doing works fine but not in my actual code..
Swyper has quit [Remote host closed the connection]
<baweaver>
Someone tell Swyper whenever they get back on that - and _ aren't the same
<adam12>
O_O nice try Illuminati
Swyper has joined #ruby
<baweaver>
Oi Swyper, what character are you using for a placeholder there on line 13?
<Swyper>
o m g
<baweaver>
....versus the ones on 50 and 53?
<baweaver>
Also use `attr_reader` for guess_word
<kaleido>
swyper no swypee
<Swyper>
rip
<Swyper>
why should I use attr_read? @baweaver
<baweaver>
Make sure to read the RSpec errors carefully, it would have probably told you something like this.
<baweaver>
`attr_reader :guess_word` will make a method for guess_word
<baweaver>
making 22, 50, and 53 unnecessary
AndChat87561 has joined #ruby
fphilipe has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
<Swyper>
it did tell me exactly what the error was but my eyes just glazed over it I'm not sure why I did not notice I using "-" as the placeholder instead of "_"
<baweaver>
Asterisk is more visually distinct `*`
jottr has joined #ruby
jottr has quit [Ping timeout: 258 seconds]
<quarters>
I was wondering how I can use vs code's debugger with bundle exec rspec
<Swyper>
quarters: are you going through AA aswell?
dsmythe has joined #ruby
<Swyper>
havenwood: ill take a look, sec
<Swyper>
thanks
cd has joined #ruby
<quarters>
Swyper, yes. haha. how'd you guess
<Swyper>
cause im doing the same thing lol
<Swyper>
AA = App Academy
<Swyper>
what section are you on?
<quarters>
but what did I do to give it away?
jottr has quit [Ping timeout: 246 seconds]
<quarters>
oh, I thought you meant alcoholics anonymous
<quarters>
jk
<Swyper>
eh I am running into the same issue with using their predefined tests and not being able to see the actual error messages lol
shtirlic has joined #ruby
<Swyper>
>_>
<quarters>
I'm on the ruby section now
<quarters>
do you have vs code's debugger setup?
<Swyper>
i dont
<Swyper>
im still doing the foundations section
<Swyper>
software engineering fundementals or w.e
<quarters>
cool. _just_ finished that
dsmythe has quit [Ping timeout: 276 seconds]
Guest2972 has quit [Ping timeout: 246 seconds]
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest2972 has joined #ruby
fphilipe has quit [Ping timeout: 276 seconds]
Guest2972 has quit [Ping timeout: 245 seconds]
waheedi has quit [Quit: waheedi]
<Swyper>
thanks havenwood, I incorporated most of your changes into my code now
fphilipe has joined #ruby
violentE has joined #ruby
fphilipe has quit [Ping timeout: 258 seconds]
jottr has joined #ruby
<havenwood>
Swyper: if you'd like any more suggestions, show your latest code!
<havenwood>
Swyper: the rubocop gem has some fancy autocorrections. i'd suggest giving it a try.
<havenwood>
Swyper: gem install rubocop
<Swyper>
what is rubocop?
<havenwood>
Swyper: then add the -a flag to auto-fix issues: rubocop -a your_ruby_file.rb
<havenwood>
Swyper: try it without -a to see what the corrections would be
<havenwood>
Swyper: rubocop 0_hangman.rb
<Swyper>
rubocop -a your_ruby_file.rb when I run it right ?
<havenwood>
Swyper: yup
<Swyper>
so in terminal type out: rubocop -a your_ruby_file.rb
<Swyper>
neato
<havenwood>
Swyper: that would "auto-correct" any issues rubocop found
<havenwood>
Swyper: it has good suggestions, typically
<havenwood>
Swyper: see if it has any fixes for your file?
<havenwood>
Swyper: (it's called "linting")
<weteamsteve>
rubocop is awesome
<Swyper>
I'm somewhat hesitant towards using attr_reader at the moment just because I don't even understand how to define and interact with attributes the long way yet 100%
jottr has quit [Ping timeout: 250 seconds]
<Swyper>
do you think thats a valid reason to not use attr_reader, or should I just use it ? ;x
<havenwood>
Swyper: attr_reader does only one thing, it exposes an instance variable with an instance method of the same name
<havenwood>
Swyper: just know that `attr_reader :x` is EXACTLY the same as `def x; @x; end`
<havenwood>
Swyper: that way you don't have to read the method definition - you know `attr_reader :x` is just a method that reads an instance variable of the same name, @x
<havenwood>
Swyper: then you can focus reading on the methods that do something beyond merely reading an instance variable
shtirlic has quit [Ping timeout: 250 seconds]
<Swyper>
my understand on concepts is still somewhat shaky
<Swyper>
def x; @x; end <-- this is a method which exposes (and declares?) and instance variable named @x ?
<Swyper>
im not sure if my understanding is correct or not
<havenwood>
Swyper: i wouldn't say "declares" really, but it does have a value of `nil` since it's declared
<havenwood>
Swyper: instance variables are `nil` when defined without a value
<havenwood>
Swyper: but yeah, it's a method which exposes an instance variable
<havenwood>
Swyper: instance.x #=> value of @x
<Swyper>
I see, so how come we do not just define instance variables at the top of the script normally eg, @@varname
<havenwood>
Swyper: so the internal attribute, which is the instance variable @x, is exposed via an attribute reader method #x.
<havenwood>
Swyper: don't use the two @@ version (class variable)
<havenwood>
Swyper: Yes, it's common practice to declare used instance variables in the #initialize method.
<havenwood>
Swyper: @x = nil
<havenwood>
Swyper: You'll often see a litany of `@xyz = ...` in an #initialize method.
shtirlic has joined #ruby
<Swyper>
ah I see
<phaul>
also attr_reader :x pretty much does the same thing as your method
<phaul>
(tiny bit more efficient by MRI, but the reason to do with attr_reader is the succintness)
<havenwood>
you don't have to wonder if the method does something more, or the instance variable name doesn't match the method name subtly or anything else - it *just* exposes an instance variable of the same name
<Swyper>
what does MRI mean? phaul
laaron has joined #ruby
<havenwood>
CRuby
<havenwood>
the reference implementation of Ruby, Matz' Ruby Interpreter (now a VM), written in C