Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@takaking216

rubyメモ

More than 1 year has passed since last update.
  • 文字列を繋ぎ合わせる場合、+を使うことで繋ぎ合わせることが出来る。
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
0
Help us understand the problem. What is going on with this article?
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
kboy_flutter_univ
KBOYのFlutter大学はKBOYが運営するFlutterアプリ開発を学ぶオンラインコミュニティです。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?