alapeno
alapeno

Reputation: 2794

What kind of Ruby data structure is this?

A very simple question, but I'm new to Ruby and not able to determine the name of this type of data structure:

location = 145.6, 56.644

I searched for point, pair, comma-seperated value etc. but was not successful. Could you tell me what this is?

Thank you

Upvotes: 5

Views: 189

Answers (3)

Drakmail
Drakmail

Reputation: 692

It is just array. In ruby you can drop out brackets in some cases:

drakmail@thinkpad-x220:~$ irb
irb(main):001:0> def test_me(a,b)
irb(main):002:1> print "a is #{a} and b is #{b}"
irb(main):003:1> end
=> nil
irb(main):004:0> test_me 5,10
a is 5 and b is 10=> nil

Upvotes: -1

az7ar
az7ar

Reputation: 5237

You can call the class method to find out

location.class

=> Array

Upvotes: 3

Related Questions