summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
authorArnie97 <arnie97@gmail.com>2015-04-11 13:09:50 +0800
committerArnie97 <arnie97@gmail.com>2015-04-11 13:09:50 +0800
commitc7f085ee34ebce89e523b10a56f9f6d5b1e4cd3a (patch)
tree7739ad481e099b59dd0393c61e898c51c35f9356 /ruby.html.markdown
parentc38d8d93135561e8c0afbe20a5b16b39917ee06c (diff)
parentf0540b93b16311ca39cf4f0ad5a9abf8dc13f223 (diff)
Merge pull request #1 from adambard/master
Fetch updates from upstream
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r--ruby.html.markdown8
1 files changed, 8 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 1883d1ad..792c9c95 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -11,6 +11,7 @@ contributors:
- ["Ariel Krakowski", "http://www.learneroo.com"]
- ["Dzianis Dashkevich", "https://github.com/dskecse"]
- ["Levi Bostian", "https://github.com/levibostian"]
+ - ["Rahil Momin", "https://github.com/iamrahil"]
---
@@ -169,6 +170,9 @@ array[1..3] #=> [2, 3, 4]
# Add to an array like this
array << 6 #=> [1, 2, 3, 4, 5, 6]
+# Check if an item exists in an array
+array.include?(1) #=> true
+
# Hashes are Ruby's primary dictionary with keys/value pairs.
# Hashes are denoted with curly braces:
hash = { 'color' => 'green', 'number' => 5 }
@@ -188,6 +192,10 @@ new_hash = { defcon: 3, action: true }
new_hash.keys #=> [:defcon, :action]
+# Check existence of keys and values in hash
+new_hash.has_key?(:defcon) #=> true
+new_hash.has_value?(3) #=> true
+
# Tip: Both Arrays and Hashes are Enumerable
# They share a lot of useful methods such as each, map, count, and more