【发布时间】:2013-05-28 20:48:23
【问题描述】:
Ruby 中next 的反义词是什么?
我正在尝试找到一个不存在的类似prev 的函数。
"b".prev 会 == "a",就像 "a".next == "b"
# A grad student at a local university thinks he has discovered a formula to
# predict what kind of grades a person will get. He says if you own less than
# 10 books, you will get a "D". If you own 10 to 20 books, you will get a "C",
# and if you own more than 20 books, you will get a "B".
# He further hypothesizes that if you actually read your books, then you will
# get a full letter grade higher in every case.
#
# grade(4, false) # => "D"
# grade(4, true) # => "C"
# grade(15, true) # => "B"
【问题讨论】:
-
没有这样的事,here 就是原因。