るりまサーチ

最速Rubyリファレンスマニュアル検索!
185件ヒット [1-100件を表示] (0.014秒)
トップページ > クエリ:bool[x] > クラス:String[x]

別のキーワード

  1. socket bool
  2. option bool
  3. variant vt_bool
  4. win32ole vt_bool
  5. bool socket

ライブラリ

キーワード

検索結果

<< 1 2 > >>

String#==(other) -> bool (103.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false...
...st[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}

@see String#eql?...

String#===(other) -> bool (103.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false...
...st[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}

@see String#eql?...

String#ascii_only? -> bool (102.0)

文字列がASCII文字のみで構成されている場合に true を返します。さもなくば false を返します。

文字列がASCII文字のみで構成されている場合に true を返します。さもなくば
false を返します。

例:

'abc123'.ascii_only? # => true
''.ascii_only? # => true
'日本語'.ascii_only? # => false
'日本語abc123'.ascii_only? # => false

String#casecmp?(other) -> bool | nil (102.0)

大文字小文字の違いを無視し文字列を比較します。 文字列が一致する場合には true を返し、一致しない場合には false を返します。

...false
"abcdef".casecmp?("ABCDEF") #=> true
"\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}") #=> true
//}

nil は文字列のエンコーディングが非互換の時に返されます。

//emlist[][ruby]{
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}") #=> nil
//}

@see String#casecmp...

String#empty? -> bool (102.0)

文字列が空 (つまり長さ 0) の時、真を返します。

文字列が空 (つまり長さ 0) の時、真を返します。

//emlist[例][ruby]{
"hello".empty? #=> false
" ".empty? #=> false
"".empty? #=> true
//}

絞り込み条件を変える

String#end_with?(*strs) -> bool (102.0)

self の末尾が strs のいずれかであるとき true を返します。

...ずれかであるとき true を返します。

@param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@see String#start_with?...
...@param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@see String#start_with?
@see String#delete_suffix, String#delete_suffix!...

String#eql?(other) -> bool (102.0)

文字列の内容が文字列 other の内容と等しいときに true を返します。 等しくなければ false を返します。

...します。
同一のオブジェクトかどうかを比較するわけではありません。
つまり、"string".eql?(str) という式を実行した場合には、
str が "string" という内容の文字列でありさえすれば常に true を返します。
同一のオブジェクト...
...String#upcase,
String
#downcase で大文字小文字を揃えてから比較してください。

Hash クラス内での比較に使われます。

@param other 任意のオブジェクト
@return true か false

//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".e...
...ql?("STRING") # => false
p "string".eql?("") # => false
p "".eql?("string") # => false

p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)

p "string".upcase.eql?("String".upcase) # =>...
...場合は
String
#casecmp? を使ってください。

Hash クラス内での比較に使われます。

@param other 任意のオブジェクト
@return true か false

//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".eql?("STRING") # => false
p "string".eql?("")...
...# => false
p "".eql?("string") # => false

p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)
//}

@see Hash, String#<=>, String#casecmp, String#==...

String#include?(substr) -> bool (102.0)

文字列中に部分文字列 substr が含まれていれば真を返します。

文字列中に部分文字列 substr が含まれていれば真を返します。

@param substr 検索する文字列

//emlist[例][ruby]{
"hello".include? "lo" #=> true
"hello".include? "ol" #=> false
"hello".include? ?h #=> true
//}

String#iseuc -> bool (102.0)

self が EUC-JP なバイト列として正当であるかどうかを判定します。

self が EUC-JP なバイト列として正当であるかどうかを判定します。

Kconv.#iseuc(self) と同じです。

//emlist[例][ruby]{
require 'kconv'

euc_str = "\
\xa5\xaa\xa5\xd6\xa5\xb8\xa5\xa7\xa5\xaf\xa5\xc8\xbb\xd8\xb8\xfe\
\xa5\xd7\xa5\xed\xa5\xb0\xa5\xe9\xa5\xdf\xa5\xf3\xa5\xb0\xb8\xc0\xb8\xec\
\x52\x75\x62\x79".force_encoding('EUC-JP')
...
<< 1 2 > >>