るりまサーチ

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

別のキーワード

  1. _builtin to_c
  2. etc sc_2_c_dev
  3. etc sc_2_c_bind
  4. tracer display_c_call
  5. tracer display_c_call=

ライブラリ

検索結果

String#center(width, padding = ' ') -> String (33363.0)

長さ width の文字列に self を中央寄せした文字列を返します。 self の長さが width より長い時には元の文字列の複製を返します。 また、第 2 引数 padding を指定したときは 空白文字の代わりに padding を詰めます。

...{
p "foo".center(10) # => " foo "
p "foo".center(9) # => " foo "
p "foo".center(8) # => " foo "
p "foo".center(7) # => " foo "
p "foo".center(3) # => "foo"
p "foo".center(2) # => "foo"
p "foo".center(1) # => "foo"
p "foo".center(10, "*")...
...# => "***foo****"
//}

@see String#ljust, String#rjust...