[問題] 請問 Ruby 有類似 Java 的 final 嗎?

看板Ruby作者 (mokuku)時間16年前 (2008/07/16 22:47), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/2 (看更多)
Java 語法裡面, 可以用 class Test { public final void test_function() {} } 這樣的定義, 讓 Test 的子類別無法重新定義 test_function() 這個 method, 即 如果 Test 子類別嘗試 class SubTest extends Test { public final void test_function() {} } 會發生 test_function() in SubTest cannot override test_function() in Test; overridden method is final 這樣的錯誤! 請問 Ruby 裡有類似的語法嗎? 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 221.169.208.119

07/16 23:02, , 1F
沒有
07/16 23:02, 1F

07/16 23:15, , 2F
喔, 感恩!
07/16 23:15, 2F
文章代碼(AID): #18VWe625 (Ruby)
文章代碼(AID): #18VWe625 (Ruby)