Delegator
bioinfornatics
bioinfornatics at fedoraproject.org
Sat Mar 3 08:42:17 PST 2012
hi,
In ruby we can delegate some method. by example:
---- Ruby ----
class MineArray
include Forwardable
def_delegators: @array, :[], :[]=, :each_with_index, :length
def initialize( array )
@array = array
end
end
-------------
this code delegate opIndexAssign opIndex, length ... attribute to his
member.
This save time, bug and line. You do not to have to write a code as:
void opIndexAssign( size_t index, T item){
array[index] = item;
}
thanks
More information about the Digitalmars-d-learn
mailing list