LoginSignup
0
0

More than 3 years have passed since last update.

[ruby]ドリルアウトプット

Posted at

内容

問題.1
名前を入力する機能を作成しましょう。
名前以外にピリオド(.)や空白があるとエラーを表示させます。

※わからない場合はAPIを利用して問題を解きましょう。
参考URL: https://docs.ruby-lang.org/ja/search/

ヒント
include?メソッドを使いましょう。

include?
include?メソッドは指定した要素が、配列や文字列内に含まれているかを判定するメソッドです。
image.png
スクリーンショット 2020-08-14 16.50.22.png

実装

image.png

解説

strに(.)か( )があったら登録できないように、include?で条件分岐させればOKです。

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