Ruby Learning # 16 Return Statement

def cube(num) num * num * num end

puts cube(3)

27

def cube(num) num * num * num 5 end

puts cube(3)

5

def cube(num) return num * num * num 5 end

puts cube(3)

27

def cube(num) return num * num * num, 70 5 end

puts cube(3)

27 70 puts cube(3)[1]

70

Recommended Posts

Ruby Learning # 16 Return Statement
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
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
About Ruby if statement
Ruby Learning # 21 While Loops
Ruby Learning # 31 Object Methods
Ruby Learning # 27 Writing Files
Ruby Learning # 35 Interactive Ruby (irb)
Ruby Learning # 9 Math & Numbers
Ruby Learning # 28 Handling Errors
Ruby Learning # 26 Reading Files
Ruby Learning # 2 Drawing a Shape
Ruby on rails learning record -2020.10.03
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
How to use Ruby return
Ruby on Rails basic learning ①
Ruby Learning # 99 Personal Programming Notebook
Ruby on rails learning record-2020.10.07 ②
[Ruby] Introduction to Ruby Error statement
Ruby Learning # 10 Getting User Input
[Ruby] Conditional bifurcation unless statement
Ruby Learning # 32 Building a Quiz
Ruby Learning # 8 Working With String
[Ruby] problem with if statement
Ruby on rails learning record -2020.10.06
[Ruby] conditional branch if statement
Completed Progate Ruby Learning Course III
Learning Ruby with AtCoder 6 [Contest 168 Therefore]
Completed Progate Ruby Learning Course II
Java learning memo (while statement, do-while statement)
Be careful when omitting return in Ruby
Learning Ruby with AtCoder 7 [Contest 168 Triple Dots]
Ruby Learning # 12 Building a Mad Libs Game
[Ruby] if statement concept of conditional expression
Ruby methods return the last evaluated value
Do not return when memoizing in Ruby
[Ruby on Rails] Button to return to top