初級 › E0061: this function takes N arguments but M were supplied の原因と直し方 › パターン2
E0061: this function takes N arguments but M were supplied の原因と直し方
関数が定義している数と異なる数の引数を渡すと、コンパイル時にE0061エラーになります。
1 fn greet(name: &str, times: i32) { 2 for _ in 0..times { 3 println!("hi {}", name); 4 } 5 } 6 7 fn main() { 8 greet(____________); ^ 9 }
error[E0061]: this function takes 2 arguments but 1 argument was supplied
空欄を埋めて実行を通す
greetは名前と回数の2つの引数が必要です。1つしか渡さないと個数が足りずエラーになります。
次の問題