Help us understand the problem. What is going on with this article?

m{|x| x } が 0 で m{|x, y| x * y } が 1 だと?

Ruby の問題です。

以下のテストをパスするメソッド m を定義せよ。

require "test/unit"

class T < Test::Unit::TestCase
  test "" do
    assert_equal 0, m{ |x| x }
    assert_equal 1, m{ |x, y| x * y }

def m(&b)
  yield b.arity == 1 ? 0 : [1, 1]

m(&->(x,y){x}) が 0 で m(&->(x,y){x*y}) が 1 だと? - Qiita

主に Ruby 使ってます。 二十年来のコンパイラー恐怖症が Rust で治癒するか?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away