end

The end() function in PHP moves the internal array pointer to the last element in the array. However in Ruby, there is no internal array pointer – as such Ruby doesn’t have an equivalent to PHP’s end() function. However Ruby does have the Array::last() method which returns the last element of an array.

PHP

$programming = array('java', 'ruby', 'python', 'php');
$language = end($programming);
print_r($language);
// => php

Ruby

programming = ['java', 'ruby', 'python', 'php'];
language = programming.last;
puts language;
=> # php
By | 2009-10-15T22:39:02+00:00 September 2nd, 2009|Categories: PHP, Ruby|Tags: , , , , |Comments Off on end

About the Author:

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.