/// Adds a constant to the chunk, checking for duplicates and returning
/// the index of the constant
Adds a constant to the chunk, checking for duplicates and returning
the index of the constant
Adds a constant to the chunk checking for duplicates and returning the index of the constant
pub fn add_constant(&mut self, value: Value) -> usize {
    for (index, constant) in self.constants.iter().enumerate() {
      if constant == &value {
        return index;
      }
    }
    self.constants.push(value);
    self.constants.len() - 1
  }
pub fn add_constant ( & mut self , value : Value ) -> usize { for ( index , constant ) in self . constants . iter ( ) . enumerate ( ) { if constant == & value { return index ; } } self . constants . push ( value ) ; self . constants . len ( ) - 1 }
Adds a constant to the chunk, checking for duplicates and returning
the index of the constant
Adds a constant to the chunk checking for duplicates and returning the index of the constant
&mut self
value
Value