PHP to Ruby
Convert PHP code into Ruby!
-
array_key_exists
Posted on April 8th, 2009 No commentsReturns TRUE if the given argument is set in the array. The argument passed in can be any value possible for an array index.
PHP
$a = array('first' => 1, 'second' => 2); var_dump( array_key_exists('first', $a) ); // => true
Ruby
animals = {:sheep => 1, :cow => 2}; puts animals.include?(:cow); # => true
Leave a reply


