Am I Missing Something? Getting Length of Array

So, I have a list of arrays, and I want to loop through the list of arrays, and send a array into the method, and sleep for the amount of notes in the array I’m sending in.

I have been looking for documentation on it, and I can’t find it. The RubyDocs page I found on the array doesn’t have size or length or count that I can find.

I found a workaround where I loop through and count on a variable, then use that, but there has to be a better way. I’m doing this to refactor code, and though I made it modular, I didn’t exactly shrink my code line count at all, so I want a more elegant solution if possible.

Can someone point me in the direction of some documentation?

Edit: Since most of them in the sequence are 2, 3, or 4, I’m going to hardcode them for now, but I would like to figure out how to get the count dynamically still if possible.

Hi Skelly…

I’m no array-mechanic but something like?

Eli…

flute = [ 76, 74, 80, 76, 76, 80, 74, 78]
puts flute.length
1 Like

I must just be having a bad morning. :rofl:

I haven’t really done much with arrays since most of my stuff has just been samples so far, or long single notes.

For the life of me, I could not find a reference to that method anywhere when I was looking for it…

Oh well. Now I know.

#ThereAreNoStupidQuestions

If I had a penny for every silly question I’ve ask on this
forum… Sam wouldn’t need a patreon, I’d be funding him
outright. :slight_smile:

Glad to help.

Eli.

1 Like

Thanks again.

I’ll post the thing I’m refactoring when It’s done.

It was in a state where a normie would look at it and go “OH WOW COOL!!! :D” but you guys would notice how much line space I’m wasting. :joy:

That’s what you get for trying to build and compose at the same time.

No shame in using a lot of lines to do a thing. It’s better to use a few more lines and make something comprehensible, that to refactor all the meaning out of your code in an effort to save space.

2 Likes