2
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?

More than 3 years have passed since last update.

第9回

Last updated at Posted at 2020-12-13

!Mac OS X-10.15.7 ruby-2.7.1p83

assert_equal

イコールかどうかを判断するメソッド

色の付け方

require 'colorize'
puts '赤色で出力'.red
puts 'シアンで出力'.cyan

その他

他のコードで呼び出したときにいらない部分は

if $PROGRAM_NAME == __FILE__
  assert_equal(1,1)
  assert_equal(1,2)
end

とすることで,呼び出さないようにする.

コード

require 'colorize'
def assert_equal expected, result
  p ['expected',expected]
  p ['result',result]
  if expected==result
    puts 'true'.cyan
  else
    puts 'false'.magenta
  end
end

if $PROGRAM_NAME == __FILE__
  assert_equal(1,1)
  assert_equal(1,2)
end


  • source ~/grad_members_20f/members/Kenny0704/c9.org
2
0
1

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
2
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?