LoginSignup
2
1

More than 1 year has passed since last update.

文字数の取得方法(Ruby)

Posted at

文字数の取得方法をRubyで実装しました

# 文字列の最後の文字を出力する
# 新規作成 2023/5/15

puts "文字を入力してください"
str = gets.chomp
# 文字数を取得する
num = str.length
# 1番最後の文字を出力する
puts str[num-1]

2
1
2

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
2
1