Skip to content
Browse files

Fixed indentation in code samples.

  • Loading branch information...
1 parent 1071d43 commit 4f26cf82bfc557d454c70654769c6dbefd3983a4 @mnaberez mnaberez committed Jun 2, 2009
Showing with 10 additions and 10 deletions.
  1. +10 −10 array/array_rand.markdown
View
20 array/array_rand.markdown
@@ -5,25 +5,25 @@ of the array with using a combination of the `Array#[]` method with
`Kernel#rand`.
{{code:php
-$fruit = array('apple', 'banana', 'kiwi', 'lime');
-$key = array_rand($fruit);
-print $fruit[$key]."\n";
-// => 'lime'
+ $fruit = array('apple', 'banana', 'kiwi', 'lime');
+ $key = array_rand($fruit);
+ print $fruit[$key]."\n";
+ // => 'lime'
}}
{{code:ruby
-fruit = ["apple", "banana", "kiwi", "lime"]
-fruit[rand(fruit.length)]
-# => "lime"
+ fruit = ["apple", "banana", "kiwi", "lime"]
+ fruit[rand(fruit.length)]
+ # => "lime"
}}
The Rails `ActiveSupport` library provides a simple shortcut method for this
as `Array#rand`.
{{code:rails
-fruit = ["apple", "banana", "kiwi", "lime"]
-fruit.rand
-# => "lime"
+ fruit = ["apple", "banana", "kiwi", "lime"]
+ fruit.rand
+ # => "lime"
}}
{{related:

0 comments on commit 4f26cf8

Please sign in to comment.
Something went wrong with that request. Please try again.