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?

[vim script] #がつく時とつかないときの違い

Last updated at Posted at 2024-07-07

#がつくときとつかないときの違いとは(==の場合)

結論としては、文字列同士を比較したとき、小文字大文字関係なく等しいのかを評価するかどうかです。
以下で、例を示します。

#がつかない場合↓

echo "hello" == "hello"
" -> 1(trueという意味です)

echo "hello" == "Hello"
" -> 1

#がつく場合↓

echo "hello" ==# "hello"
" -> 1

echo "hello" ==# "Hello"
" -> 0(falseという意味です)

まとめ

#がつく方がより厳密に評価するようです。
基本的には#をつけて評価を行った方が良さそうですね。

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?