PHP to Ruby
Convert PHP code into Ruby!
-
array_unshift
Posted on October 7th, 2009 No commentsThe array_unshift() function in PHP prepends elements onto the beginning of an array.
PHP
$cue = array('http', 'https', 'ftp'); array_unshift($cue, 'ssh'); print_r($cue); /* Array ( [0] => ssh [1] => http [2] => https [3] => ftp ) */
Ruby has an identical Array method, named unshift:
Ruby
cue = [ "http", "https", "ftp" ]; cue.unshift('ssh'); puts cue; # => [ "ssh", "http", "https", "ftp"]


