Difference Between Blocks and Arrarys


I'm getting hung up on the difference between blocks and arrays. Are arrays simply for strings of text? And blocks are for numbers and do/end statements? Is it really that simple?


Blocks are a means of making code available to methods that you are calling.
It's not a value, it's just code. "Here's code that you can run if you like"

Methods and procs are values, you can store them, for example in an array, and execute each one - you can't do this with blocks, since they are not values.

Arrays contain data like integers and strings or as mentioned above, methods. So it's just values in a specific order, useful for handling many values that don't make sense to put into individual variables. For example you might have an array that contains information about each package that a delivery truck carries, so that array would be "all packages" as opposed to variables a b c d e f g h .. for each package


Hey, an array looks just like this arrayname = [1, 2, 3, 4, ] . you can name it anything you want numbers = [ 5, 7] , an array can also contain strings like Cinderella = [ "black hair", "black gloves", "white band"]
A block is just the code, you've probably heard someone saying the "block of code" . A code block is just a way of grouping statements(codes). Blocks are just are chunks of code between braces or between do and end statements .With blocks, you can group a set of instructions together so that they can be passed around your program.