Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Latest commit

 

History

History
26 lines (20 loc) · 608 Bytes

File metadata and controls

26 lines (20 loc) · 608 Bytes

array_values

{{notice: This function's solution uses a Ruby Hash object since Ruby arrays don't use associative key/value pairs. See Array for more details. }}

To get the values of a hash in Ruby, we can use the Hash#values method.

{{code:php $dinner = array('fruit' => 'apple', 'meat' => 'chicken'); $result = array_values($dinner); var_export($result); // => array(0 => 'apple', 1 => 'chicken') }}

{{code:ruby dinner = {:fruit => "apple", :meat => "chicken"} p dinner.values # => ["apple", "chicken"] }}

{{related: array/array_keys
}}