Ruby Learning # 30 Initialize Method

class Book attr_accessor :title, :author, :pages def initialize(title, author, pages) @title = title @author = author @pages = pages end end

book1 = Book.new("Harry Potter","JK Rowling",400) book2 = Book.new("Lord of the rings","Tolkein",500)

puts book1.author

Recommended Posts

Ruby Learning # 30 Initialize Method
[Ruby] initialize method
Ruby Learning # 24 Exponent Method
Ruby learning 4
Ruby learning 5
Ruby learning 3
initialize method
Ruby learning 2
Ruby learning 6
Ruby learning 1
Ruby Learning # 25 Comments
Ruby to_s method
Ruby Learning # 13 Arrays
Ruby Learning # 1 Introduction
Ruby Learning # 34 Modules
Ruby Learning # 14 Hashes
[Ruby] slice method
[Ruby] end_with? method
[Ruby] Method memorandum
Ruby Learning # 33 Inheritance
Ruby Learning # 15 Methods
Ruby build method
Ruby accessor method
ruby map method
abbreviation for ruby method
Ruby learning points (basic)
Java learning 2 (learning calculation method)
Ruby Learning # 29 Classes & Objects
Ruby Learning # 20 Case Expressions
Java learning memo (method)
Ruby Thread # [] = method notes
Ruby Learning # 17 If Statements
Ruby Learning # 21 While Loops
Ruby Learning # 31 Object Methods
Ruby Learning # 27 Writing Files
definition of ruby method
Ruby Learning # 35 Interactive Ruby (irb)
Ruby Learning # 9 Math & Numbers
Ruby Learning # 28 Handling Errors
Ruby Learning # 26 Reading Files
Ruby Learning # 23 For Loops
[Ruby] Method definition summary
Ruby Learning # 16 Return Statement
Ruby Learning # 2 Drawing a Shape
Ruby on rails learning record -2020.10.03
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 ①
Integer check method with ruby
Ruby algorithm (inject, method definition)
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] Notes on gets method
Ruby on rails learning record -2020.10.06