Module: DaruLite::Vector::Setable
- Included in:
- DaruLite::Vector
- Defined in:
- lib/daru_lite/vector/setable.rb
Instance Method Summary collapse
-
#[]=(*indexes, val) ⇒ Object
Just like in Hashes, you can specify the index label of the DaruLite::Vector and assign an element an that place in the DaruLite::Vector.
-
#set_at(positions, val) ⇒ Object
Change value at given positions.
Instance Method Details
#[]=(*indexes, val) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/daru_lite/vector/setable.rb', line 36 def []=(*indexes, val) cast(dtype: :array) if val.nil? && dtype != :array guard_type_check(val) modify_vector(indexes, val) update_position_cache end |
#set_at(positions, val) ⇒ Object
Change value at given positions
17 18 19 20 21 |
# File 'lib/daru_lite/vector/setable.rb', line 17 def set_at(positions, val) validate_positions(*positions) positions.map { |pos| @data[pos] = val } update_position_cache end |