I’m trying to follow a programming exercise in Python (2.x) which follows these steps to make a simple test for building a test runner:
test= WasRun("testMethod") print test.wasRun test.testMethod() print test.wasRun
Notice how “testMethod”, the string, defines a function with the same name which acts on the “WasRun” object
So far, my adaptation attempt goes like this
test = WasRun("testMethod") #<- mutable Julia struct println(test.wasRun) run(test) # not exactly the same meaning println(test.wasRun)
run separately like
run(wr::WasRun) = wr.wasRun = true
but it seems the closest adaptation would be either
testMethod(wr::WasRun) = wr.wasRun = true
test.testMethod() # <- testMethod() being defined during the constructor call from 'test'
by itself. This last solution seems weird for Julia, because it would mean the struct would have
testMethod() being defined in the constructor and being part of the structure.
I don’t have to follow the example 1:1, but I was wondering if there is a viable solution to adapt this behavior.
Thanks a lot in advance