开发者社区> 问答> 正文

[Ruby] void value expression?报错

我在 Ruby 中设计了一个函数,但是系统报错:

def is_upper(_c)
  _int = _c.ord
  return _int >= 65 and _int <= 90
end

不知道这是什么原因?

展开
收起
爱吃鱼的程序员 2020-06-06 21:14:10 411 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <pre><code>
    

    def is_upper(_c) _int = _c.ord if _int >= 65 if _int <= 90 return true end end return false end

    变换了句法,就 ok 了。

                        <p>return 的优先级比and 高,加个括号也行。</p>
    
    2020-06-06 21:14:20
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载