大佬教程收集整理的这篇文章主要介绍了如何在Ruby中模拟Java类注释?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
(我们有答案,概括一下
http://bens.me.uk/2009/java-style-annotations-in-ruby)
这里有一个小例子:
class A Annotate! _Hello color: 'red',ancho: 23 _goodbye color: 'green',alto: -123 _foobar color: 'blew' def m1; end def m2; end _foobar color: 'cyan' def m3; end end
当然,没有一个testuite,Ruby代码将不会完成:
require 'test/unit' class TestAnnotations < Test::Unit::TESTCase def test_that_m1_is_Annotated_with_Hello_and_has_value_red assert_equal 'red',A.Annotations(:m1)[:Hello][:color] end def test_that_m3_is_Annotated_with_foobar_and_has_value_cyan assert_equal 'cyan',A.Annotations[:m3][:foobar][:color] end def test_that_m1_is_Annotated_with_goodbye assert A.Annotations[:m1][:goodbye] end def test_that_all_Annotations_are_there Annotations = { m1: { Hello: { color: 'red',ancho: 23 },goodbye: { color: 'green',alto: -123 },foobar: { color: 'blew' } },m3: { foobar: { color: 'cyan' } } } assert_equal Annotations,A.Annotations end end@H_801_5@ @H_801_5@
以上是大佬教程为你收集整理的如何在Ruby中模拟Java类注释?全部内容,希望文章能够帮你解决如何在Ruby中模拟Java类注释?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。