Created
June 5, 2011 22:28
-
-
Save chadwpry/1009499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initial code project | |
#!/usr/bin/env ruby | |
class Person | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def say(text) | |
if block_given? | |
yield @name | |
else | |
puts "#{name} says #{text}" | |
end | |
end | |
def name | |
@name | |
end | |
end | |
neal = Person.new("neal") | |
neal.say "hello world" | |
neal.say(nil) do |name| | |
puts "#{name} says this is my way of saying something" | |
end | |
# Memory allocation and references | |
Buffer1 | |
Session: | |
id: nil | |
name: nil | |
host: nil | |
Buffer2 | |
Session: | |
id: nil | |
name: nil | |
host: nil | |
s = Buffer1 | |
s = Buffer2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment