Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Alphonse Cuccurullo
Alphonse Cuccurullo
2,513 Points

Is_a? and integer?

w = []

def add_to_array(arg) puts"Type in something to add in this array." name = gets.chomp if name.is_a? integer? name = name.to_i arg.push(name) puts"added number." else arg.push(name) puts"Added string" end end

add_to_array(w)

the goal is to add to this array whether its a string or number i think i messed up the part with the interger? and is_a?

1 Answer