0
0

More than 3 years have passed since last update.

Ruby学習#29 Classes & Objects

Posted at

class Book
attr_accessor :title, :author, :pages
end

book1 Book.new()
book1.title = "Harry Potter"
book1.author = "HK Rowling"
book1.pages = 400

puts book1.pages

400

book2. = Book.new()
book2.title = "Lord of the rings"
book2.author = "Tolkein"
book2.pages = 500

puts book2.author

Tolkein

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0