mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 06:47:54 +02:00
Ruby updates
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
language: ruby
|
language: ruby
|
||||||
contributors:
|
contributors:
|
||||||
- ["David Underwood", "http://theflyingdeveloper.com"]
|
- ["David Underwood", "http://theflyingdeveloper.com"]
|
||||||
|
- ["Joel Walden", "http://joelwalden.net"]
|
||||||
---
|
---
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -154,7 +155,7 @@ new_hash = { defcon: 3, action: true}
|
|||||||
new_hash.keys #=> [:defcon, :action]
|
new_hash.keys #=> [:defcon, :action]
|
||||||
|
|
||||||
# Tip: Both Arrays and Hashes are Enumerable
|
# Tip: Both Arrays and Hashes are Enumerable
|
||||||
# This means they share a lot of useful methods such as each, map, count, and more
|
# They share a lot of useful methods such as each, map, count, and more
|
||||||
|
|
||||||
# Control structures
|
# Control structures
|
||||||
|
|
||||||
@@ -277,8 +278,8 @@ class Human
|
|||||||
@name
|
@name
|
||||||
end
|
end
|
||||||
|
|
||||||
# A class method; uses self to distinguish from instance methods. (Can only be called on class, not an instance).
|
# A class method uses self to distinguish from instance methods.
|
||||||
|
$ It can only be called on the class, not an instance.
|
||||||
def self.say(msg)
|
def self.say(msg)
|
||||||
puts "#{msg}"
|
puts "#{msg}"
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user