【发布时间】:2009-04-08 03:25:52
【问题描述】:
超级初学者易分红宝石题。我试图通过编程Project Euler 问题来学习一些红宝石。所以我有一个测试
class ProjectEuler_tests < Test::Unit::TestCase
@solution = 123456 # Not the answer so as not to be a spoiler
def test_problem_1
assert_equal(@solution, ProjectEuler1.new.solve)
end
end
但这不起作用,@solution 在测试运行时为零。在类范围内分配它的正确方法是什么?
【问题讨论】: