# 12. call and response

What am I supposed to put??

``````age = 26

[#whatamisupposedtoputoverhere].respond_to?(:next)``````

What are the instructions of this exercise?

``````                            Instructions
``````

Rather than checking to see if our age variable is an integer, check to see if it will .respond_to? the .next method. (.next will return the integer immediately following the integer itâ€™s called on, meaning 4.next will return 5.)

Based on that instruction, what should you use with `.respond_to?`?

what is the correct code.

You know the code:

age = 26

[26.next].respond_to?(:push)

Good for you. LOL.

Maybe I donâ€™t quite understand this so I will explain my thought process.

Based on the example provided

[1, 2, 3].respond_to?(:push)

is how to use the respond_to? to check if :push would work correctly on this array.

Given this example and the task â€ścheck to see if it will .respond_to? the .next method.â€ť where the thing we are checking is â€śage = 26â€ť wouldnâ€™t the solution be

[age].respond_to?(:next)

I have tried this and it evaluates to false. I know there are other proposed solutions in this thread but I donâ€™t quite understand WHY they are true as opposed to this which falls in line perfectly with the example code.

This is what worked for me

`````` age.respond_to?(:next)
``````

The hint says to use :next as the argument for respond_to?
So I think my answer is the one that was intended even though other answers may work.

4 Likes

Try this.
(age).respond_to?(:next)

i think this intention of this part is just to show us whether â€ś:nextâ€ť can work for â€śageâ€ť. it seems this part confuss most of beginner including me at first.

I forgot to reply to you it seems. Probably too late now but we never know:

``````[age].respond_to?(:next)
``````

canâ€™t work because it constructs an array with age inside it. What we want is not to know if an array containing `age` responds to `next`, what we want to know is if the object `age` itself responds to `next`.

Look at @scriptsurfer03439â€™s answer for how to do it.

who is right can you help me

age.respond_to?(:next)

works fine for me too.

The instruction says that,

Rather than checking to see if our age variable is an integer, check to see if it will .respond_to? the .next method. (.next will return the integer immediately following the integer itâ€™s called on, meaning 4.next will return 5.)

base from the samples, the object is an array of numbers since they are inside . The respond_to? method is trying to check if the methods .push and .to_sym can be applicable to this array.

[1, 2, 3].respond_to?(:push)

and

[1, 2, 3].respond_to?(:to_sym)

note: Thereâ€™s nothing to be worry about the last phrased sentence of the instruction. It only defines how .next method works.

This is how I understand the task here.
Hope it helps!