Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3297 > unrolled thread
| Started by | Siratinee Sukachai <ploy.sukachai@gmail.com> |
|---|---|
| First post | 2011-04-21 02:55 -0500 |
| Last post | 2011-04-21 06:59 -0500 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.ruby
error: undefined method Siratinee Sukachai <ploy.sukachai@gmail.com> - 2011-04-21 02:55 -0500
Re: error: undefined method Brian Candler <b.candler@pobox.com> - 2011-04-21 04:20 -0500
Re: error: undefined method Siratinee Sukachai <ploy.sukachai@gmail.com> - 2011-04-21 04:34 -0500
Re: error: undefined method Gunther Diemant <g.diemant@gmx.net> - 2011-04-21 06:59 -0500
| From | Siratinee Sukachai <ploy.sukachai@gmail.com> |
|---|---|
| Date | 2011-04-21 02:55 -0500 |
| Subject | error: undefined method |
| Message-ID | <0bfc818aaade1cf1852b483c69c7074b@ruby-forum.com> |
I create a method named splitDot which is spliting a dot "."
Inside a class, I call that method but I got the error.
This is the full error:
app/controllers/convert_to_yaml.rb:14: undefined method `splitDot' for
ConvertToYaml:Class (NoMethodError)
from app/controllers/convert_to_yaml.rb:13:in `each'
from app/controllers/convert_to_yaml.rb:13
My method:
private
def splitDot(s)
return s.split('.')
end
And I call the method like this:
text.each{|t|
array = splitDot(t)
}
Any suggestions?
--
Posted via http://www.ruby-forum.com/.
[toc] | [next] | [standalone]
| From | Brian Candler <b.candler@pobox.com> |
|---|---|
| Date | 2011-04-21 04:20 -0500 |
| Message-ID | <6bf9e978bb2982e4bc2fb9eda30f7736@ruby-forum.com> |
| In reply to | #3297 |
Siratinee Sukachai wrote in post #994228:
> Any suggestions?
Yes - make a standalone minimal program which demonstrates the problem.
You're showing your code out of context - we can't see what class each
method is defined in. If you can make a simple program which
demonstrates the problem, then we can run it, and can debug it for you -
although more than likely you'll find the problem yourself as part of
the process of boiling it down to a simple case.
Right now, the code you've posted isn't even valid Ruby:
class ConvertToYaml
{
...
} # wrong
class ConvertToYaml
...
end # right
--
Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | Siratinee Sukachai <ploy.sukachai@gmail.com> |
|---|---|
| Date | 2011-04-21 04:34 -0500 |
| Message-ID | <2e2ff191871d12ac4711f321acc82be5@ruby-forum.com> |
| In reply to | #3297 |
Yeah, I'm sorry. Actually, I mean the code is
class ConvertToYaml
...
text.each{|t|
array = splitDot(t)
}
...
private
def splitDot(s)
return s.split('.')
end
end
--
Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | Gunther Diemant <g.diemant@gmx.net> |
|---|---|
| Date | 2011-04-21 06:59 -0500 |
| Message-ID | <BANLkTikeEY3XQKUE1q4=7M0ZHXotXZ+ghw@mail.gmail.com> |
| In reply to | #3300 |
It seems that you call splitDot as class method and not inside another
instance method. But you define splitDot to be an instance method.
Try
def self.splitDot(s)
s.split '.'
end
PS: Maybe even better: remove the splitDot method completly and use
the split method directly:
text.each { |t| array = t.split('.') }
2011/4/21, Siratinee Sukachai <ploy.sukachai@gmail.com>:
> Yeah, I'm sorry. Actually, I mean the code is
>
> class ConvertToYaml
> ...
> text.each{|t|
> array = splitDot(t)
> }
> ...
>
> private
>
> def splitDot(s)
> return s.split('.')
> end
> end
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.ruby
csiph-web