Just wondering:
Is it possible to overwrite parts of a code without overwriting the entire method?
I.E. If we have a method like this
def method
for i in 100...110
p i
end
p "done"
end
and you wanted to overwrite p "done" and change it to p "complete", but wanted to leave everything above it as it is and you don't want to rewrite the entire method.
Is that possible?
You should re-write it into the following. (A more compatible method)
def method
for i in 100...110
p i
end
end
Then in the class you want to re-define it, do -
alias: name_refering_to_original_method: method
def method
name_refering_to_original_method
p "Complete"
end
Thanks, but the reason I wanted it was so for my scripts, if I had to do minor modifications to the default scripts (but ones that required some overwriting, so not straight additions), I could just do it in a code snippet, thus making it easier to share the scripts.
Unfortunately, your method would still involve rewriting part of the default scripts ;9
Thanks anyway though.
One of the goals of the SDK is to split many of the default scripts up into a lot of methods thus allowing easier customization.
This naturally causes a lot of compatibility problems, but meh.
Anyway. You might be able to modify the parse tree directly or you might be able to read and modify the original method in question.
If you are able to either of these ways it will probably not be simple what you have to do. I'm only guessing, I haven't researched.