1

I need to define a function in a script that is loading another script, and use it in the script being loaded. For example:

main file:

require 'file'
def FunctionA()
    #define function here
end

file.rb:

FunctionA()

I cannot move the definition to the file being included. Is there any way I can do this?

1
  • I am not. The one being included is un-compressed using Zlib. The other one I am writing. Also, ruby seems to not count my comments as lines or something, as my line numbers are always off. Is there a way to fix this? Commented Jun 7, 2014 at 1:15

1 Answer 1

3

For the use case presented in your question right now, just move require 'file' to the end.

def FunctionA()
    #define function here
end

require 'file'
Sign up to request clarification or add additional context in comments.

2 Comments

This was my first thought. Does the error "uninitialized constant Font (NameError)" mean it is looking for a variable, not a function?
Wanted to discuss with you Ruby JSON class.. Could you propose a time, when you will be free ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.