Hi all,
This is my first post here, so don't dish out the loser points to me so heartily.
I have only recently gotten into Ruby, and I was writing my own methods that I might use in a couple future programs (they were YAML things, like open and closing a file, and reading a file). I saved it as yaml.rb . However, when I require it ( require 'yaml.rb') and then try to call a method I had defined in yaml.rb, I get an error saying that the method had not been defined yet:
test.rb:8: undefined method `yaml_save' for main:Object (NoMethodError)
yaml_save was the method I had tried to use.
Any thoughts? Suggestions? Flames?
Part II
The missing command
Today I was in the car and was coding on my dad's laptop (Windows XP), and I was writing a shuffling algorithm. I had used the .pop command in it once, and it worked. But then all of a sudden Ruby was saying that there was no command 'pop'. The syntax I had used it in was like so:
b = some_array.pop
Once again, any thoughts? Suggestions? Flames?
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.
Hi all,
This is my first post here, so don't dish out the loser points to me so heartily.
I have only recently gotten into Ruby, and I was writing my own methods that I might use in a couple future programs (they were YAML things, like open and closing a file, and reading a file). I saved it as yaml.rb .
That's unlucky - there's a yaml.rb in the standard library which require loads in preference to yours. Try renaming your yaml.rb, or moving it into a folder so that you can call "require 'ari/yaml'", or some equivalent. As an aside, it's usual (and, under some circumstances, required) to leave off the file extension with require.
Part II
The missing command
Today I was in the car and was coding on my dad's laptop (Windows XP), and I was writing a shuffling algorithm. I had used the .pop command in it once, and it worked. But then all of a sudden Ruby was saying that there was no command 'pop'. The syntax I had used it in was like so:
b = some_array.pop
Sounds like some_array isn't actually an array. Care to post the code that's causing the error?
You should really use, some other name for your library because as
pointed Alex, its in conflict with ruby standard library.
···
On 4/21/07, Ari Brown <ari@aribrown.com> wrote:
On Apr 20, 2007, at 10:20 PM, james.d.masters@gmail.com wrote:
> The code that cause this issue would be nice... but it looks like you
> are calling it from an Object something like this:
>
> a = Object.new
> a.yaml_save