QuoteTry with * in the argument definition of the method like "def bind(*variable_pointer, min, max)".
Tried doing that, gives me a syntax error. And I did some superficial reading and *args is used to pass multiple arguments. So "def bind(*args)" would work, but not "def bind(*args, arg2)".
QuoteBasically in Ruby there are Reference Type and Value Type variables.
By Valut Types, do you mean 'literals'?
QuoteIf I am not wrong, in Ruby the value types are Numerics, Strings and some other which I don't know from memory right now. Check my e-book, I explained it there.
I will.
So you know why I want this, right? I did some testing and using [[a, 1].max, 99].min is WAY slower than using conditional branches. I wrote a method and tested some operations. When the "method" way was faster than the "direct" way, I took a closer lok and thus I found out I don't know how to pass pointers.
Anyway, I tried this in the Numeric class:
class Numeric
def bind(min, max)
if self < min
self = min
elsif self > max
self = max
end
end
end
I got a syntax error at "self = min" line...