Ruby study notes (variables & functions)

Overview

This time, as a memorandum, I will write a memo that I learned about variables and functions, which is especially basic in programming.

variable


a = 'hello' #Local variables
A = 'world' #constant
$global = 'ruby' #Global variables

Declare local variables in lowercase and constants in all uppercase (custom). If it is a global variable, put $ before the variable.

function


def func(argument)
   puts argument

a = 'hello world'
func(a)
>>> hello world

The function was easy to get used to because it was written very similar to Python.

reference

https://www.sejuku.net/blog/12879

Recommended Posts

Ruby study notes (variables & functions)
Ruby variables and functions (methods)
Jigsaw study notes
JavaFX study notes
Ruby Hash notes
Docker study notes
[Java] Study notes
About Ruby variables
Ruby Thread # [] = method notes
Ruby variables and methods
Maven basic study notes
Ruby study memo (conditional branching)
[Ruby] Exception handling in functions
Use ruby variables in javascript.
Ruby study memo (recursive function)
[Ruby] Notes on gets method
[Ruby ~ Iterative processing ~] Study memo 4
Ruby Study Memo (Test Driven Development)
Internal class and lambda study notes
[Ruby] Display the contents of variables