LoginSignup
0
0

More than 3 years have passed since last update.

Rubyのメソッド

Posted at

downcaseメソッド

大文字を小文字に変換してくれるメソッド

ruby
def down(str)
  puts str.downcase
end 

str("HelloRuby")

#出力は全て小文字で、hellorubyとなります

sliceメソッド

一部の文字を切り取りしたい場合に使用するメソッド

ruby
def cut(str)
  puts str.slice(2)
end

str("HelloRuby")

#lが出力されます

また、切り取る範囲も指定することもできます

ruby
def cut(str)
  puts str.slice(2..5)
end

str("HelloRuby")

#lloRが出力されます
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