Function artichoke_backend::convert::check_to_ary

source ·
pub fn check_to_ary(
    interp: &mut Artichoke,
    value: Value
) -> Result<Value, Error>
Expand description

Fallible conversion of the given value to a Ruby Array or nil via #to_ary.

If the given value is a array, it is returned. If the give value responds to a #to_ary method, it is called. Otherwise, a TypeError is raised.

If this function returns Ok, the returned Value is guaranteed to be either a Ruby Array or nil.

§Errors

  • If the call to #to_ary returns an error, that error is returned.
  • If the call to #to_ary returns anything other than an Array or nil, a TypeError is returned.