37件ヒット
[1-37件を表示]
(0.255秒)
検索結果
先頭5件
-
String
# to _ s -> String (18137.0) -
self を返します。
...uby]{
p "str".to_s # => "str"
p "str".to_str # => "str"
//}
このメソッドは、文字列を他のクラスのインスタンスと混ぜて処理したいときに有効です。
例えば返り値が文字列か nil であるメソッド some_method があるとき、
to_s メソッド......を使うと以下のように統一的に処理できます。
//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_method(5).to_s.downcase
//}... -
Symbol
# downcase -> Symbol (18125.0) -
大文字を小文字に変換したシンボルを返します。
...大文字を小文字に変換したシンボルを返します。
(self.to_s.downcase.intern と同じです。)
:FOO.downcase #=> :foo
@see String#downcase... -
Symbol
# downcase(*options) -> Symbol (18125.0) -
大文字を小文字に変換したシンボルを返します。
...大文字を小文字に変換したシンボルを返します。
(self.to_s.downcase.intern と同じです。)
:FOO.downcase #=> :foo
@see String#downcase... -
String
# to _ str -> String (6137.0) -
self を返します。
...uby]{
p "str".to_s # => "str"
p "str".to_str # => "str"
//}
このメソッドは、文字列を他のクラスのインスタンスと混ぜて処理したいときに有効です。
例えば返り値が文字列か nil であるメソッド some_method があるとき、
to_s メソッド......を使うと以下のように統一的に処理できます。
//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_method(5).to_s.downcase
//}... -
NEWS for Ruby 3
. 0 . 0 (12.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ng#center
* String#chomp
* String#chop
* String#delete
* String#delete_prefix
* String#delete_suffix
* String#downcase
* String#dump
* String#each_char
* String#each_grapheme_cluster
* String#each_line
* String#gsub
* String#lju......tinuously improve the coverage of language features, analysis performance, and usability.
//emlist[][ruby]{
# test.rb
def foo(x)
if x > 10
x.to_s
else
nil
end
end
foo(42)
//}
//emlist{
$ typeprof test.rb
# Classes
class Object
def foo : (Integer) -> String?
end
//}
== Miscellaneo...