Help us understand the problem. What is going on with this article?

rubyメモ

  • 文字列を繋ぎ合わせる場合、+を使うことで繋ぎ合わせることが出来る。
input = "aaa" + "bbb" + "ccc"
puts input

"aaabbbccc"
  • ""内で特定の記号で区切られた文字列を配列にし分割する。
input = "aaa;bbb;ccc;"
a = input.split(';');
a.each do |a|
  puts a
end

aaa
bbb
ccc
  • 最初の文字を大文字にし、後の文字は小文字にする。
input = "aaabbbccc".capitalize
puts input

Aaabbbccc
  • 文字列の順番を逆に並べ替える
input = "abcde".reverse
puts input

edcba
  • 全ての文字列を大文字で返す。
input = "abcde".upcase
puts input

ABCDE
  • 引数で渡された文字列の二乗の数を返す。
def aaa(input)
  input ** 2
end

bbb_input = 5
puts aaa(bbb_input)

25
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした