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
<ih8u> havenwood: thank you
<ih8u> i will play around some more with those options
<ih8u> would you happen to have any insight into why i wouldn't be able to send a float to c with mruby?
<ih8u> i can send `0`, but not `0.0`, `Float(0.0)`, or `0.0.to_f`
<ih8u> `
<ih8u> mrb_value float_test(mrb_state *mrb, mrb_value self) {
<ih8u> mrb_float f;
<ih8u> mrb_get_args(mrb, "f", &f);
<ih8u> printf("%f\n", f);
<ih8u> return mrb_nil_value();
<ih8u> }
<ih8u> `
<ih8u> that's what the function looks like on the c side
<o0x1eef> weaksauce: 2007 :o
<weaksauce> it's an oldie
konsolebox has joined #ruby
konsolebox has quit [Ping timeout: 276 seconds]
brokkoli_origin has quit [Ping timeout: 252 seconds]
crespire has quit [Remote host closed the connection]
crespire has joined #ruby
konsolebox has joined #ruby
markong has quit [Ping timeout: 276 seconds]
brokkoli_origin has joined #ruby
brokkoli_origin has quit [Remote host closed the connection]
brokkoli_origin has joined #ruby
cappy has joined #ruby
sympt has quit [Ping timeout: 245 seconds]
snoojin has joined #ruby
fercell has joined #ruby
chen has quit [Quit: No Ping reply in 180 seconds.]
chen has joined #ruby
<ih8u> also, is there a shortcut for Array#size - 1?
<ih8u> i.e. get the last index
slothby has quit [Ping timeout: 252 seconds]
slothby has joined #ruby
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
brw has quit [Quit: The Lounge - https://thelounge.chat]
brw has joined #ruby
<weaksauce> you can make one ih8u
<weaksauce> class Array; def last_index; self.size - 1; end
<weaksauce> end
Guest64 has joined #ruby
cappy has quit [Quit: Leaving]
Guest64 has quit [Quit: Client closed]
<ih8u> weaksauce: indeed, i'm just kind of surprised there isn't something like that built in
<weaksauce> ih8u if you want the last element it's just some_array[-1]
<ih8u> or `last`
<weaksauce> not sure how often a last index is useful
<ih8u> useful when handling array overflows
<ih8u> actually, it comes up a lot
<weaksauce> i guess maybe if you're doing c style ruby
<weaksauce> usually a < array.size should suffice right
<ih8u> not even
<ih8u> i'm not talking about iteration
<ih8u> whatever, it doesn't matter
<ih8u> i know i can do it
<ih8u> i was just making sure there wasn't some convenience method i was overlooking
<weaksauce> i'm not talking about iteration either but ot
<weaksauce> ok
<ih8u> consider a situation where you have values stored in an array, and you need to cycle through them
snoojin has quit [Quit: Connection closed for inactivity]
<ih8u> it's like iteration, but not in one go
<ih8u> you track the index, and have the ability to increment and decrement it
<ih8u> eventually, that index is going to need to be cycled back around
<weaksauce> is that not what mod is for
<weaksauce> %
<ih8u> show me what that looks like
<weaksauce> index % array.size
<ih8u> nice
<ih8u> that idea never occurred to me
<ih8u> though it's not as immediately obvious what's going on
<weaksauce> it's actually a c thing tbf
<ih8u> i guess i don't dislike what you call "c style" in this case
<weaksauce> but ruby is for c programmers to have nice thing
<weaksauce> s
<weaksauce> i mean c style has a place
<weaksauce> just depends on what you're doing
<ih8u> handling index overflows lol
<weaksauce> yeah if you want it to cycle and don't care that it's going over like a ring buffer would modulus is the way to go
<weaksauce> or if you want it to stay between an upper bound and 0 mod is the way
hwpplayer1 has joined #ruby
grenierm has joined #ruby
hwpplayer1 has quit [Remote host closed the connection]
konsolebox has quit [Ping timeout: 250 seconds]
hwpplayer1 has joined #ruby
brokkoli_origin has quit [Ping timeout: 260 seconds]
hwpplayer1 has quit [Remote host closed the connection]
brokkoli_origin has joined #ruby
brokkoli_origin has quit [Remote host closed the connection]
brokkoli_origin has joined #ruby
<balo> reggelt