Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Created April 25, 2013 10:56
Show Gist options
  • Select an option

  • Save 1dolinski/5458966 to your computer and use it in GitHub Desktop.

Select an option

Save 1dolinski/5458966 to your computer and use it in GitHub Desktop.
def add_listener(listener)
(@listeners ||= [] << listener)
end
add_listener("chris")
@listeners && @listeners.each do |x| # why not just @listeners.each ??
puts x
end
@mikebaldry
Copy link
Copy Markdown

  @listeners = []

  def add_listener(listener)
    @listeners << listener
  end

  add_listener("chris")


  @listeners.each do |x| 
    puts x
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment