简单的红宝石“或"问题 [英] Simple Ruby 'or' question

查看:15
本文介绍了简单的红宝石“或"问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在控制台中:

@user.user_type = "hello"
@user.user_type == "hello"
  true
@user.user_type == ("hello" || "goodbye")
  false

如何编写最后一条语句,以便检查 @user.user_type 是否包含在两个字符串之一中?

How do I write the last statement so it checks to see if @user.user_type is contained in one of the two strings?

推荐答案

["hello", "goodbye"].include? @user.user_type

这篇关于简单的红宝石“或"问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆