Ruby Learning # 29 Classes & Objects

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

Recommended Posts

Ruby Learning # 29 Classes & Objects
Ruby learning 4
Ruby learning 5
Ruby learning 3
Ruby learning 2
Ruby learning 6
Ruby learning 1
Ruby Learning # 25 Comments
Ruby Learning # 13 Arrays
Ruby Learning # 1 Introduction
Ruby Learning # 34 Modules
Ruby Learning # 14 Hashes
Ruby Learning # 33 Inheritance
Ruby Learning # 15 Methods
Comparison of JavaScript objects and Ruby classes
[Ruby] Classes and instances
Ruby learning points (basic)
Ruby Learning # 20 Case Expressions
Ruby Learning # 24 Exponent Method
Ruby Learning # 17 If Statements
Ruby Learning # 21 While Loops
Ruby Learning # 31 Object Methods
Ruby Learning # 27 Writing Files
Ruby Learning # 35 Interactive Ruby (irb)
Ruby classes and instances
Ruby Learning # 9 Math & Numbers
Ruby Learning # 28 Handling Errors
Ruby Learning # 26 Reading Files
Ruby Learning # 23 For Loops
Ruby Learning # 16 Return Statement
Ruby Learning # 2 Drawing a Shape
Ruby on rails learning record -2020.10.03
Is Ruby all objects, true?
Ruby on rails learning record -2020.10.04
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby Learning # 18 If Statements (Con't)
Ruby on Rails basic learning ①
Ruby Learning # 11 Building a Calculator
Ruby Learning # 99 Personal Programming Notebook
Ruby on rails learning record-2020.10.07 ②
Ruby Learning # 10 Getting User Input
Ruby Learning # 32 Building a Quiz
Ruby Learning # 8 Working With String
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
[Ruby] Singular methods and singular classes
About Ruby classes and instances
Ruby methods and classes (basic)
Creating Ruby classes and instances
[Ruby] Singular methods and singular classes
Ruby Learning # 19 Building a Better Calculator
Completed Progate Ruby Learning Course III
Learning Ruby with AtCoder 6 [Contest 168 Therefore]
Completed Progate Ruby Learning Course II
[Ruby] Classes, instance variables, instances, etc ...
Ruby Learning # 22 Building a Guessing Game
Learning Ruby with AtCoder 7 [Contest 168 Triple Dots]
Explanation of Ruby Time and Date objects
Ruby Learning # 12 Building a Mad Libs Game
Memorandum (Ruby: Basic Grammar: Classes and Instances)