Parv G wrote:
> I'm new to ruby coming from Java/C#.

Welcome.

> I keep on getting an error "undefined method `nextcell' for 
> TestClass:Class (NoMethodError)" , when i try to run the code below.
> if somebody can provide some insight, that would be appreciated.
> 
> class TestClass
> 
>     def nextcell
> 
>         col = 'A'
>         row = 1
>         maxCol = 'H'
>         maxRow = 5
> 
>         if (col < maxCol)
>             myNextCell = col + row.to_s
>             col = col.next
>             puts("Next Cell is #{myNextCell}")
>             return myNextCell
>         else
>             row.next
>             myNextCell = col + row.to_s
>             col.next
>             return myNextCell
>         end
>     end
> 
>     nextcell()
>     nextcell()
> end
> 
> The reason why i'm calling method nextcell() twice is to see if the 
> state of the variable has changed. is this the right approach or are my 
> variable declartions incorrect?

You defined nextcell (I'd prefer next_cell) as an instance method. You
can only call it on an object of class TestClass.

If you comment the 2 calls to nextcell you can try the following:

tc = TestClass.new
puts tc.nextcell.inspect
puts tc.nextcell.inspect

As you will notice both outputs are the same.

All your variables are local to the method nextcell, no state is changed.

If you want the object to change its content you will have to define
instance variables.

def initialize
  @col = 'A'
end

In nextcell you have to change all occurences of 'col' to '@col'.

Stefan