0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

20250906_AP_変数の呼び出し方

0
Posted at

値呼び出し

引数として渡した変数のコピーが関数に渡される。
関数内で値が変更されても、元の変数には影響しない。

function add10(x):
x = x + 10
return x

a = 5
b = add10(a) # aの値 5 がコピーされて関数に渡される

b = 15, a = 5(aは変わらない)

参照呼び出し

引数として渡した変数の参照が関数に渡される。
関数内で値を変更すると、元の変数にも影響が及ぶ。

function add10(ref x):
x = x + 10

a = 5
add10(a) # aの参照が渡される

a = 15(関数内の操作が元のaを直接変える)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?