Loading workspace environment...
Get started with Ruby syntax, structure, and writing your first program.
# Ruby 3.3 Syntax & Learning Sandbox
class Book
attr_reader :title, :author
def initialize(title, author)
@title = title
@author = author
end
def info
""#{@title}" by #{@author}"
end
end
library = [
Book.new("The Pragmatic Programmer", "Andrew Hunt"),
Book.new("Clean Code", "Robert C. Martin")
]
library.each { |b| puts b.info }