Ruby Learning # 31 Object Methods

class student attr_accessor :name, :major, :gpa def initalize(name,major,gpa) @name = name @major = major @gpa = gpa end

def has_honors if @gpa >= 3.5 return true end return false end end

student1 = Student.new("Jim","Business",2.6) student2 = Student.new("Pam","Art",3.6)

puts student2.has_honors

Recommended Posts

Ruby Learning # 31 Object Methods
Ruby Learning # 15 Methods
Ruby learning 4
Ruby learning 3
Ruby learning 2
Ruby learning 6
Ruby learning 1
Ruby Learning # 13 Arrays
Ruby Learning # 1 Introduction
Ruby Learning # 34 Modules
Ruby Learning # 14 Hashes
Ruby Learning # 33 Inheritance
About Ruby methods
Ruby Learning # 30 Initialize Method
Ruby learning points (basic)
Ruby Learning # 29 Classes & Objects
Ruby Learning # 20 Case Expressions
Ruby Learning # 24 Exponent Method
Ruby Learning # 17 If Statements
Ruby Learning # 21 While Loops
Ruby Learning # 27 Writing Files
About Ruby instance methods
Ruby Learning # 35 Interactive Ruby (irb)
Ruby Learning # 9 Math & Numbers
Ruby variables and methods
[Ruby] methods, instance methods, etc ...
Ruby Learning # 28 Handling Errors
Ruby Learning # 26 Reading Files
Ruby Learning # 23 For Loops
Ruby Learning # 16 Return Statement
[Learning Memo] Metaprogramming Ruby 2nd Edition: Chapter 3: Methods
Ruby Learning # 2 Drawing a Shape
Basic methods of Ruby hashes
Basic methods of Ruby arrays
Ruby on rails learning record -2020.10.04
Ruby on rails learning record -2020.10.05
Ruby Learning # 18 If Statements (Con't)
Explanation about Ruby Range object
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 ②
Three Bit Manipulation Methods (Ruby)
Ruby Learning # 10 Getting User Input
Ruby Learning # 32 Building a Quiz
Ruby Learning # 8 Working With String
What are Ruby class methods?
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
About Ruby and object model
[Ruby] Singular methods and singular classes
[Ruby] Class methods, instance methods, etc.
Ruby variables and functions (methods)
Ruby methods and classes (basic)
Explanation about Ruby String object
[Ruby] Singular methods and singular classes
Ruby Learning # 19 Building a Better Calculator
Completed Progate Ruby Learning Course III
Convert ruby object to JSON format
Write Ruby methods using C (Part 1)
Learning Ruby with AtCoder 6 [Contest 168 Therefore]