我的程序是爲了返回用戶輸入的任何字符串的反轉版本,但是如果字符串包含任何符號,它也應該報告錯誤的輸入。我似乎無法找到辦法做到這一點。順便說一下,該程序帶有一個IO.java模塊。這裏是我的代碼 public class ReverseWords{
public static void main(String [ ] args){
String word= IO.readString()
我不能夠理解這個代碼的邏輯: class VowelFinder
include Enumerable
def initialize(string)
@string = string
end
def each
@string.scan(/[aeiou]/) do |vowel|
yield vowel
end