havenwood changed the topic of #ruby to: Ruby 3.2.2, 3.1.4, 3.3.0-preview1: https://www.ruby-lang.org | Rules: https://ruby-community.com | Logs: https://libera.irclog.whitequark.org/ruby
hightower3 has joined #ruby
hightower4 has quit [Ping timeout: 246 seconds]
John_Ivan has joined #ruby
konsolebox has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
konsolebox has quit [Ping timeout: 256 seconds]
caedmon has joined #ruby
konsolebox has joined #ruby
caedmon has quit [Ping timeout: 246 seconds]
caedmon has joined #ruby
caedmon has quit [Ping timeout: 256 seconds]
caedmon has joined #ruby
konsolebox has quit [Ping timeout: 245 seconds]
caedmon has quit [Ping timeout: 246 seconds]
Sankalp has quit [Ping timeout: 245 seconds]
Sankalp has joined #ruby
caedmon has joined #ruby
caedmon has quit [Ping timeout: 252 seconds]
konsolebox has joined #ruby
caedmon has joined #ruby
caedmon has quit [Ping timeout: 248 seconds]
konsolebox has quit [Quit: Quit]
caedmon has joined #ruby
desnudopenguino has quit [Remote host closed the connection]
desnudopenguino has joined #ruby
reset has quit [Quit: reset]
hd1 has joined #ruby
hd1 has left #ruby [#ruby]
_ht has joined #ruby
caedmon has quit [Ping timeout: 246 seconds]
caedmon has joined #ruby
m_antis has quit [Read error: Connection reset by peer]
konsolebox has joined #ruby
caedmon has quit [Ping timeout: 248 seconds]
konsolebox has quit [Quit: Leaving]
grenierm has joined #ruby
_ht has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
crespire1 has quit [Remote host closed the connection]
brw9 is now known as brw
crespire has joined #ruby
brw has quit [Quit: The Lounge - https://thelounge.chat]
brw has joined #ruby
Sankalp has quit [Ping timeout: 252 seconds]
Sankalp has joined #ruby
taupiqueur_shiny has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
janusx has joined #ruby
janusy has joined #ruby
janusx has quit [Ping timeout: 245 seconds]
neok0 has joined #ruby
janusy has quit [Ping timeout: 245 seconds]
konsolebox has joined #ruby
taupiqueur_shiny has joined #ruby
janusy has joined #ruby
neok0 has quit [Ping timeout: 245 seconds]
konsolebox has quit [Ping timeout: 252 seconds]
janusy has quit [Ping timeout: 250 seconds]
dviola has joined #ruby
gr33n7007h has quit [Quit: WeeChat 4.0.3]
gr33n7007h has joined #ruby
crespire has quit [Ping timeout: 246 seconds]
crespire has joined #ruby
bhaak has quit [Ping timeout: 245 seconds]
konsolebox has joined #ruby
grenierm has quit [Ping timeout: 246 seconds]
bhaak has joined #ruby
willfish has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
joto has quit [Quit: The Lounge - https://thelounge.chat]
joto has joined #ruby
constxqt has quit [Ping timeout: 248 seconds]
joto has quit [Remote host closed the connection]
joto has joined #ruby
nona has quit [Quit: WeeChat 4.0.2]
nona has joined #ruby
joto has quit [Read error: Connection reset by peer]
joto has joined #ruby
shokohsc51084 has joined #ruby
shokohsc5108 has quit [Ping timeout: 256 seconds]
shokohsc51084 is now known as shokohsc5108
konsolebox has quit [Ping timeout: 246 seconds]
shokohsc5108 has quit [Ping timeout: 245 seconds]
shokohsc5108 has joined #ruby
constxqt has joined #ruby
user23 has joined #ruby
konsolebox has joined #ruby
joto has quit [Read error: Connection reset by peer]
joto has joined #ruby
<ox1eef_> Lasange++
<adam12> good morning
<adam12> lasagna++ :)
<ox1eef_> I guess it should be lasanga += 1, being #ruby and all xD
<ox1eef_> g'morning, and happy Friday!
shokohsc51083 has joined #ruby
shokohsc5108 has quit [Ping timeout: 244 seconds]
shokohsc51083 is now known as shokohsc5108
victori has quit [Ping timeout: 256 seconds]
victori has joined #ruby
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
some14u has joined #ruby
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
some14u has joined #ruby
otisolsen70 has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
shokohsc5108 has quit [Read error: Connection reset by peer]
taupiqueur_shiny has joined #ruby
shokohsc5108 has joined #ruby
taupiqueur_shiny has quit [Ping timeout: 246 seconds]
sam113101 has quit [Remote host closed the connection]
sam113101 has joined #ruby
_ht has joined #ruby
willfish has quit [Ping timeout: 246 seconds]
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<johnjaye> ruby has this super generous operator overloading right
<johnjaye> so you could define lasanga++ if you wanted to
<adam12> johnjaye: There is no ++ in Ruby.
<adam12> I think there's a blog post about why.
<johnjaye> then how do things like [] and << get defined.
<johnjaye> or are those only for the core and you can't define them as a user
<adam12> johnjaye: I don't have a perfect example because I don't remember teh reasoning, but one of them could be that all Fixnum's are singletons.
<adam12> johnjaye: So 1++ might return 2, but it can't mutate itself to be 2.
<adam12> so you'd need the assignment anyways.
<johnjaye> no i mean operators in general. can you define them in ruby
<adam12> And nobody would do foo = foo++
<adam12> johnjaye: Sure. You can override Integer#+ if you want (I wouldn't tho obviously :P)
<johnjaye> so is it more that you could define ++ but it would be ambiguous
<johnjaye> or maybe there's some check that ++ would fail while building or intepreting?
<adam12> I am not sure `++` is a legit method name, tho `+` is. Ruby might see `++` as `Class#+` with `+` as an argument? Or it might just fail parsing all together.
m_antis has joined #ruby
hightower3 has quit [Remote host closed the connection]
hightower3 has joined #ruby
caedmon has joined #ruby
konsolebox has quit [Ping timeout: 248 seconds]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
graywolf has joined #ruby
<ox1eef_> adam12: Integers being immutable is definitely at least one reason. "++" suggests mutation, but you have to reassign to increment an integer in Ruby.
<f4z4> johnjaye: you can override only a specific set of operators. It’s not like in C++. See https://ruby-doc.org/3.2.2/syntax/methods_rdoc.html#label-Method+Names
<f4z4> You cannot define new ones…
<ox1eef_> You could use define_method to define ++ (or any other name AFAIK) but you couldn't call it as expected (eg foo++) since the syntax is not understood. .send(:'++') should work though.
graywolf has quit [Quit: WeeChat 4.0.2]
ua_ has quit [Excess Flood]
ua_ has joined #ruby
<johnjaye> ah i see
<leftylink> you could also mislead someone with a long line and hope it scrolls off the right side of their screen
<leftylink> pandabot rb using(Module.new { refine(NilClass) { def +@; end } }); class Incrementable; def initialize(n) @n = n end; def +(_) @n += 1 end end; a = Incrementable.new(5); a++ p
<leftylink> they'll never notice.
<ox1eef_> Clever :) I like it.
<johnjaye> f4z4: that page doesn't exactly make it clear.
<johnjaye> but your saying you can't defin new operators
<johnjaye> you can define methods but they start with a letter is what it says
caedmon has quit [Ping timeout: 260 seconds]
<ox1eef_> You can define +, -, etc as you'd expect: def +(other); self + other; end - and you can define unary operators with the syntax def +@, or def !@. I think unary operators have the most potential to be used in interesting ways.
<ox1eef_> pandabot rb class Foo; def +@; 1; end; ++Foo.new
<ox1eef_> pandabot rb class Foo; def +@; 1; end; end; ++Foo.new
grenierm has joined #ruby
taupiqueur_shiny has joined #ruby
konsolebox has joined #ruby
_ht has quit [Quit: _ht]
tomtmym has quit [Quit: Gone.]
grenierm has quit [Ping timeout: 246 seconds]
otisolsen70 has quit [Quit: Leaving]
taupiqueur_shiny has quit [Ping timeout: 246 seconds]
konsolebox has quit [Ping timeout: 246 seconds]
Linux_Kerio has joined #ruby
fercell has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
user23 has quit [Remote host closed the connection]
Linux_Kerio has quit [Ping timeout: 248 seconds]