1
Ruby中的next
与之相反的是什么? 我试图找到一个不存在的函数,如prev
。是否存在与String.next相反的内容?
"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"
有没有像这一点,[这里](http://stackoverflow.com/questions/16716522/opposite-字符串中的下一个在红宝石)是原因。 – squiguy