Struct ruru::Hash
[−]
[src]
pub struct Hash { // some fields omitted }
Hash
Methods
impl Hash
[src]
fn new() -> Self
fn at<T: Object>(&self, key: T) -> AnyObject
Retrieves an AnyObject
from element stored at key
key.
Examples
use ruru::{Fixnum, Hash, Symbol, VM}; let mut hash = Hash::new(); hash.store(Symbol::new("key"), Fixnum::new(1)); assert_eq!(hash.at(Symbol::new("key")).as_fixnum(), Fixnum::new(1));
Ruby:
hash = {}
hash[:key] = 1
hash[:key] == 1
fn store<K: Object, V: Object>(&mut self, key: K, value: V) -> AnyObject
Associates the value
with the key
.
Both key
and value
must be types which implement Object
trait.
Examples
use ruru::{Fixnum, Hash, Symbol, VM}; let mut hash = Hash::new(); hash.store(Symbol::new("key"), Fixnum::new(1)); assert_eq!(hash.at(Symbol::new("key")).as_fixnum(), Fixnum::new(1));
Ruby:
hash = {}
hash[:key] = 1
hash[:key] == 1
Trait Implementations
impl From<Value> for Hash
[src]
impl Object for Hash
[src]
fn value(&self) -> Value
Usually this function just returns a value
of current object. Read more
fn class(&self) -> Class
Returns a Class
struct of current object Read more
fn send(&self, method: &str, arguments: Vec<AnyObject>) -> AnyObject
Calls a given method on an object similarly to Ruby Object#send
method Read more
fn as_any_object(&self) -> AnyObject
Converts struct to AnyObject
Read more
fn instance_variable_get(&self, variable: &str) -> AnyObject
Sets an instance variable for object Read more
fn instance_variable_set<T: Object>(&mut self, variable: &str, value: T) -> AnyObject
Gets an instance variable of object Read more