PHP to Ruby
Convert PHP code into Ruby!
-
range
Posted on July 26th, 2009 No commentsThe range() function creates an array containing a range of elements in PHP, however in Ruby the Range object is used to handle ranges of integers or strings.
PHP
$chars = range('a', 'c'); print_r($chars); // => array(0 => 'a', 1 => 'b', 2 => 'c')
Ruby
chars = 'a'..'c' chars.each {|item| print "#{item}, " } # => a, b, c,
Leave a reply


