官术网_书友最值得收藏!

Variable code implementation

Now let's dive into the code. For a basic example, I'm going to store my name in a variable:

name = "Jordan" 

If you go to repl.it and run this, you can see my name displayed in the Terminal:

Additionally, a variable can hold more than one value, and in many cases it's called an array (for which we will dedicate an entire section, later in this course). Consider this example:

address = ["123", "Anystreet", "Anytown", "TX"] 

Again, in the Terminal, you can see all these values, but they will come with the square brackets. In fact, these brackets denote that it is an array of variables:

Later, we'll walk through how variables can also hold methods, which allow programs to store logic in addition to data that can be called when needed.

As you can see, the syntax for using variables in Ruby is quite straightforward. Unlike many other languages, Ruby variables do not require semicolons or a data type to be declared. This feature is possible because Ruby is a Just-in-Time (JIT) interpreted language, which automatically recognizes the data type based on what variables are stored.

主站蜘蛛池模板: 阳山县| 金阳县| 镇康县| 平乐县| 二手房| 高雄县| 保定市| 长治市| 山阴县| 彩票| 资中县| 高要市| 闽清县| 家居| 宜川县| 日土县| 黔江区| 阳信县| 阳泉市| 舟山市| 乳源| 华阴市| 阿拉善盟| 广宗县| 兴和县| 井研县| 高雄市| 麻江县| 保山市| 鲁甸县| 芒康县| 仁布县| 神木县| 临桂县| 竹溪县| 定结县| 太仆寺旗| 舟山市| 阿尔山市| 海口市| 教育|