<johnjaye>
hmm. to call a class method on an instance is invalid I guess?
<johnjaye>
e.g. f = File.new("test.txt"), you can't do f.absolute_path(f)
seydar has joined #ruby
<seydar>
I'm working with glimmer_dsl_libui, and I'm having trouble with getting multiline_entry to appear below the rectangle. https://paste.tomsmeding.com/g5Lju4gy
<seydar>
anyone have experience with glimmer? or is there another GUI library I should be using?
konsolebox has joined #ruby
<johnjaye>
oh strange, so IO class has a readlines class method and a readlines instance method
desnudopenguino has quit [Ping timeout: 245 seconds]
desnudopenguino1 has joined #ruby
Linux_Kerio has joined #ruby
desnudopenguino1 is now known as desnudopenguino
seydar has quit [Quit: leaving]
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<konsolebox>
johnjaye: Not strange at all
<johnjaye>
yes i noticed it in some other places too
<johnjaye>
that would explain why ruby doesn't let me call a class method from an instance
<johnjaye>
I was confused about one other thing.
<johnjaye>
it makes intuitive sense that I can call Dir.entries with a File argument instead of a string argument
<johnjaye>
but I don't see it in the documentation for it. help("Dir.entries") just says it takes a string. is it calling to_s on the argument somehow?
<konsolebox>
johnjaye: Class methods that are similarly named to an instance method are mostly shortcuts which does the instantation internally.
<johnjaye>
or is ruby just being super nice and has some safeguard for this case
<konsolebox>
johnjaye: Many methods that expect a string do call to_s implicitly yes, but some strictly reject non-strings.
<johnjaye>
hmm. if i do f.to_s I get "#<File:0x0000... >"
<johnjaye>
i assume ruby is doing something here though
konsolebox has quit [Ping timeout: 244 seconds]
John_Ivan has quit [Ping timeout: 256 seconds]
konsolebox has joined #ruby
Vonter has joined #ruby
MarvelousWololo has joined #ruby
kokoro has quit [Ping timeout: 245 seconds]
kokoro has joined #ruby
gr33n7007h has quit [Quit: WeeChat 4.0.2]
gr33n7007h has joined #ruby
_ht has joined #ruby
konsolebox has quit [Ping timeout: 240 seconds]
konsolebox has joined #ruby
_ht has quit [Remote host closed the connection]
grenierm has joined #ruby
f4z4 has joined #ruby
donofrio_ has joined #ruby
donofrio has quit [Ping timeout: 260 seconds]
infinityfye has joined #ruby
infinityfye has quit [Client Quit]
teclator has joined #ruby
otisolsen70 has joined #ruby
otisolsen70 has quit [Read error: Connection reset by peer]
victori has quit [Ping timeout: 246 seconds]
bas317 has joined #ruby
<bas317>
Hi I'm new here, trying to do the ruby Koans. I realized I made a mistake, but need further explanation.
<bas317>
class DiceSet
<bas317>
attr_reader :values
<bas317>
@values = []
<bas317>
...
<bas317>
end
<bas317>
I figured these lines are executed when the .rb file is required, but I wonder what happens to @values as it is no instance variable, but DiceSet.class_variables is also empty. Does it get thrown away after the require? If so, why is it allowed to be named @values instead of for example values only?
f4z4 has quit [Quit: No more compute for now… zZZzzz]
f4z4 has joined #ruby
crespire has quit [Killed (NickServ (GHOST command used by crespire1))]
crespire1 has joined #ruby
konsolebox has quit [Ping timeout: 245 seconds]
duderonomy has quit [Ping timeout: 246 seconds]
f4z4 has quit [Quit: No more compute for now… zZZzzz]
f4z4 has joined #ruby
Tempesta has quit [Quit: See ya!]
<leftylink>
that @values is a class instance variable.
<bas317>
leftylink thanks! I'll look it up what it exactly means.
<leftylink>
pandabot rb class A; @foo = 19980819; def self.bar; @foo end end; A.bar
<leftylink>
here we see that the class method was able to access the class instance variable. just like how an instance method would be able to access an instance variable
<bas317>
Oohhhh, so DiceSet, being a class, is also an object, having instance variables. Now I get it. I'm starting to read about class_variables and the "@@" keyword, then I should be back on track! Thanks again!
f4z4 has quit [Quit: No more compute for now… zZZzzz]
desnudopenguino has quit [Ping timeout: 246 seconds]
otisolsen70_ has quit [Read error: Connection reset by peer]
otisolsen70_ has joined #ruby
otisolsen70_ has quit [Remote host closed the connection]
grenierm has quit [Ping timeout: 246 seconds]
MarvelousWololo has quit [Read error: Connection reset by peer]
shokohsc510 has quit [Ping timeout: 256 seconds]
desnudopenguino has joined #ruby
shokohsc510 has joined #ruby
f4z4 has joined #ruby
<leftylink>
pandabot rb class A; @@cv = :cv_not_modified_GOOD; @civ = :civ_not_modified_GOOD; def self.foo; [@@cv, @civ] end end; class B < A; @@cv = :cv_modified_BAD; @civ = :civ_modified_BAD end; A.foo