havenwood changed the topic of #ruby to: Ruby 3.3.6 (3.4.0-rc1) https://www.ruby-lang.org | Log https://libera.irclog.whitequark.org/ruby
mange has joined #ruby
Vonter has quit [Ping timeout: 260 seconds]
cappy has joined #ruby
Linux_Kerio has quit [Ping timeout: 265 seconds]
eddof13 has quit [Quit: eddof13]
cahoots_ has quit [Quit: Client closed]
polishdub has quit [Ping timeout: 264 seconds]
polishdub has joined #ruby
cappy has quit [Quit: Leaving]
Rounin has quit [Ping timeout: 252 seconds]
eddof13 has joined #ruby
Rounin has joined #ruby
mms has quit [Ping timeout: 276 seconds]
<ih8u> is there a way to set a local folder to not use rbenv?
<ih8u> i need to use a non-rbenv-installed mruby
eddof13 has quit [Quit: eddof13]
jasfloss has quit [Ping timeout: 276 seconds]
admin1234 has joined #ruby
eddof13 has joined #ruby
TomyWork has quit [Ping timeout: 260 seconds]
snoojin has joined #ruby
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
jasfloss has joined #ruby
eddof13 has joined #ruby
Vonter has joined #ruby
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
eddof13 has quit [Quit: eddof13]
nirvdrum4 has joined #ruby
nirvdrum has quit [Read error: Connection reset by peer]
nirvdrum4 is now known as nirvdrum
konsolebox has joined #ruby
notzmv has quit [Ping timeout: 265 seconds]
snoojin has quit [Quit: Connection closed for inactivity]
eddof13 has joined #ruby
eddof13 has quit [Quit: eddof13]
mange has quit [Remote host closed the connection]
powersurge36047 has joined #ruby
powersurge3604 has quit [Ping timeout: 252 seconds]
powersurge36047 is now known as powersurge3604
jmcgnh has quit [Ping timeout: 244 seconds]
<nakilon> ih8u: `rbenv local system`
<nakilon> the "system" is how rbenv calls what was preinstalled before it
<nakilon> oh wait, mruby? then not sure, you somehow have to pass the paths, etc.; tell if you figure it out
jmcgnh has joined #ruby
konsolebox_ has joined #ruby
konsolebox has quit [Ping timeout: 264 seconds]
hwpplayer1 has joined #ruby
notzmv has joined #ruby
Linux_Kerio has joined #ruby
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
nmollerup has quit [Remote host closed the connection]
hwpplayer1 has quit [Read error: Connection reset by peer]
nmollerup has joined #ruby
hwpplayer1 has joined #ruby
hwpplayer1 has quit [Remote host closed the connection]
konsolebox_ has quit [Ping timeout: 248 seconds]
<ih8u> nakilon: thank you, you taught me something
Guest1 has joined #ruby
Guest1 has quit [Client Quit]
___nick___ has quit [Ping timeout: 265 seconds]
__nick__ has joined #ruby
TomyWork has joined #ruby
Linux_Kerio has quit [Ping timeout: 260 seconds]
brokkoli_origin has quit [Remote host closed the connection]
donofrio has joined #ruby
eddof13 has joined #ruby
brokkoli_origin has joined #ruby
teardown has quit [Ping timeout: 264 seconds]
teardown has joined #ruby
donofrio has quit [Ping timeout: 248 seconds]
eddof13 has quit [Quit: eddof13]
powersurge3604 has quit [Quit: Ping timeout (120 seconds)]
powersurge3604 has joined #ruby
eddof13 has joined #ruby
hwpplayer1 has joined #ruby
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
sarna has quit [Ping timeout: 248 seconds]
sarna has joined #ruby
user71 has joined #ruby
donofrio has joined #ruby
donofrio has quit [Ping timeout: 252 seconds]
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
cappy has joined #ruby
donofrio has joined #ruby
donofrio has quit [Ping timeout: 260 seconds]
guest-12423 has joined #ruby
guest-12423 has quit [Quit: Client closed]
guest-12423 has joined #ruby
<guest-12423> I've got an issue where an instance variable accessed within the method of a class is nil (accessed through the attr_accessor, not @variable or self.variable)
<guest-12423> It seems like undefined behavior, I think ruby is confusing the instance variable for a local variable, how can I debug this?
graywolf has joined #ruby
<weaksauce> guest-12423 can you share any code?
cappy_ has joined #ruby
cappy has quit [Ping timeout: 260 seconds]
patrick has quit [Ping timeout: 248 seconds]
patrick_ is now known as patrick
cappy_ is now known as cappy
<guest-12423> no matter what I do, daily_usage is declared, recurring_uses is declared, current_amount is nil
<guest-12423> The puts do show values though so I imagine this is some sort of lookup issue
<o0x1eef> You need to prefix self
<o0x1eef> 'self.current_amount -= ...'
<o0x1eef> self.current_amount -= daily_usage
<guest-12423> o0x1eef: thanks for that, I realized that
<guest-12423> but I'm wondering what is actually going on here?
<guest-12423> or is it not worth investigating
<guest-12423> current_amount should be looked up to the attr_accessor created getter, right?
<guest-12423> what is it actually accessing if not that?
Linux_Kerio has joined #ruby
<weaksauce> that's always been a bit unclear to me... self is the implicit object to send to without any prefix so why is it required there?
<guest-12423> if it is a genuine ruby bug, I'm cool to file something. I feel like I'm just overlooking something there
<guest-12423> is there a way to look up the chain look-up for a specific call
<weaksauce> attr_accessor just creates two methods on the object
<weaksauce> a getter and a setter
<guest-12423> and why is recurring uses not nil
<guest-12423> i have a feeling that only the last call to attr_accessor works
<weaksauce> which should be def name() @name; end and def name=(value); @name = value; end
<o0x1eef> I don't think you need attr_accessor at all. You could use attr_reader, then @current_amount -= daily_usage.
<weaksauce> nah attr_accessor can be called many times
<weaksauce> or you can do it on one line
<weaksauce> attr_accessor :current_amount, :recurring_uses is fine
<o0x1eef> Back to your question, I believe your assignment is ambigious from Ruby's point of view. It doesn't know if you meant a local variable, or the setter. It assumes a local variable. You have to remove the ambiguity for it to work.
<weaksauce> ah yeah good point... very obvious in hindsight
<guest-12423> o0x1eef then why does it assume correctly for the other variable? could it just be random (name of variable or something like that)
<o0x1eef> In the other cases you're not doing an assignment but reading from the getter.
<o0x1eef> foo -= 2 expands to 'foo = foo - 2'. So this might make it clearer.
<guest-12423> okay I took a deeper look o0x1eef
<guest-12423> you are correct, it appears that the assignment statement
<guest-12423> somehow flags to ruby that this might be a local variable
<o0x1eef> The other thing to know is that at parse time, ruby looks for assignments like this one, and assigns 'current_amount' a value of nil. Even before the code runs.
<guest-12423> I guess for pure curiosity, how come the puts prints the right 'current_amount'
<guest-12423> if ruby had already assigned it a value of nil
<guest-12423> the puts prints the right 'current_amount' but when accessing the variable in a debugger session, it returns nil
<o0x1eef> That resolves to self.current_amount. The lookup rules a bit different for looking up the value vs assigning a value to a variable.
<guest-12423> i guess this is just unnecessary talk, I should just be more explicit
<guest-12423> thanks
<o0x1eef> These are good questions. I suggest you hang around because I'm sure there's others who have a better understanding of this than me.
<guest-12423> I'll produce an easier gist then, maybe someone can shed some light on it
<o0x1eef> if false
<o0x1eef> foo = 1
<o0x1eef> end
<o0x1eef> p foo
<o0x1eef> This will return 'nil'.
patrick_ has joined #ruby
patrick has joined #ruby
patrick has quit [Changing host]
patrick_ is now known as patrick
patrick_ has joined #ruby
mms has joined #ruby
powersurge36042 has joined #ruby
powersurge3604 has quit [Ping timeout: 272 seconds]
powersurge36042 is now known as powersurge3604
eddof13 has quit [Quit: eddof13]
admin1234 has quit [Ping timeout: 265 seconds]
hwpplayer1 has quit [Read error: Connection reset by peer]
hwpplayer1 has joined #ruby
eddof13 has joined #ruby
hwpplayer1 has quit [Quit: see you]
entropie has quit [Ping timeout: 276 seconds]
entropie has joined #ruby
__nick__ has quit [Ping timeout: 260 seconds]
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
admin1234 has joined #ruby
hwpplayer1 has joined #ruby
eddof13 has joined #ruby
admin1234 has quit [Ping timeout: 265 seconds]
admin1234 has joined #ruby
eddof13 has quit [Quit: eddof13]
<havenwood> guest-12423: Use the instance variable directly, like: @current_amount += 42
<havenwood> An instance variable makes it clear to the reader it's just an instance variable, and saves a method call so less overhead.
user71 has quit [Quit: Leaving]
<havenwood> guest-12423: A `bareword` checks first for a local variable in the local table then does method lookup. A `bareword =` sets a local variable.
guest-12423 has quit [Quit: Client closed]
cappy has quit [Quit: Leaving]
admin1234 has quit [Ping timeout: 276 seconds]
admin1234 has joined #ruby
r3m has quit [Quit: WeeChat 4.6.0-dev]
r3m has joined #ruby
hwpplayer1 has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.4)]
MyNetAz has quit [Read error: Connection reset by peer]
Linux_Kerio has quit [Ping timeout: 264 seconds]
admin1234 has quit [Ping timeout: 265 seconds]
MyNetAz has joined #ruby
mms` has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
mms has quit [Ping timeout: 246 seconds]
<o0x1eef> Agreed and good points. FWIW it is very rare that I would use attr_accessor. There has to be a good reason to do that first, and until that's the case, I default to attr_reader (or even just hiding the state as an internal instance variable)
mms` has quit [Remote host closed the connection]
<o0x1eef> Oh they left :) Too bad
mms has joined #ruby
mms has quit [Remote host closed the connection]
mms has joined #ruby
admin1234 has joined #ruby
admin1234 has quit [Ping timeout: 265 seconds]
admin1234 has joined #ruby
graywolf has quit [Quit: WeeChat 4.5.0]
admin1234 has quit [Ping timeout: 248 seconds]
admin1234 has joined #ruby