Skip to content

Instantly share code, notes, and snippets.

@chadwpry
Created June 5, 2011 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadwpry/1009499 to your computer and use it in GitHub Desktop.
Save chadwpry/1009499 to your computer and use it in GitHub Desktop.
# 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