-3
所以我有這個數組動態創建:陣列迭代
array = [ "Name can't be blank", "Email can't be blank",
"Email is invalid", "Password can't be blank",
"Password is too short (minimum is 6 characters)",
"Password confirmation can't be blank" ]
什麼,我想通過這個數組迭代,如果有值:
"Password can't be blank"
驗證是否存在價值:
"Password confirmation can't be blank"
並擺脫它。
所以返回的數組將是:
array = [ "Name can't be blank", "Email can't be blank",
"Email is invalid", "Password can't be blank",
"Password is too short (minimum is 6 characters)"]
非常感謝!
爲什麼要麻煩?如果密碼爲空白,我寧願刪除「太短」警告。 –
你剛剛寫到:'array.delete(「密碼確認不能爲空」)如果array.include?(「密碼不能爲空」)' – user2422869
「詢問代碼的問題必須證明對問題得到解決包括嘗試解決方案,爲什麼他們不工作,以及預期的結果。另請參見:[堆棧溢出問題清單](http://meta.stackexchange.com/questions/156810/stack-overflow-question-清單)」 –