markdown 公共要点 - 图灵 - 预备工作第3天完成的项目汇编

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 公共要点 - 图灵 - 预备工作第3天完成的项目汇编相关的知识,希望对你有一定的参考价值。

**What is a pomodoro break?**
Breaks in a pomodoro are short intermissions (3 - 5 minutes) and taken between each pomodoro to avoid mental fatique.  When four pomodoro are complete the breaks become longer (15 to 30 minutes).

Variables
**How do you create a variable?**
Using irb, assign the variable name and the variable value on either side of an equal sign (=).
For example:  variable = 10

**What did you learn about the rules for naming variables?**
Different types of variables have different naming conventions.
The following rules apply: 

Class Variables:  defined using a double "at" sign (@@); can be followed by digits, underscores and letters
@@class


Global Variables:  starts with a dollar sign ($) followed by other characters.
$global

Instance Variables:  defined using an "at" sign (@) followed by a name; lowercase letters recommended.
@instance

Local Variables: lowercase letters followed by characters and underscores to separate words.
local_variables

**How do you change the value of a variable?**

To change the value of a variable in IRB:

enter_variable_name = 5
enter_variable_name
=> 5
enter_variable_name = 10 (previously enter_variable_name = 5)
enter_variable_name
=> 10

Datatypes
**How can you find out the class of a variable?**
To discover the class of a variable in IRB:

enter_variable_name.class
=> Integer

What are two string methods?
Two different string methods are:

.length
.upcase

**How can you change an integer to a string?**

Utilize the to_s method as follows:

10.to_s
=> "10"

Strings

**Why might you use double quotes instead of single quotes in Ruby?**
Double quotes ensures the functionality of interpolation.

**What is this used for in Ruby: #{}?**
Interpolation.  Allows for the ability to embed a Ruby statetment within a string.

**How would you remove all the vowels from a string?**
I would use the .delete method to remove all the vowels from a string.
Example:  "a plain old string".delete('aeiou')

Input & Output
**What do 'print' and 'puts' do in Ruby?**
print:  Prints information to the user, but doesn't create a new line after printing.
puts:  Prints information to the user, and creates a a new line after printing.

**What does 'gets' do in Ruby?**
The gets method gets the user's response in a string format, which is convertible using other methods, like to_i.

以上是关于markdown 公共要点 - 图灵 - 预备工作第3天完成的项目汇编的主要内容,如果未能解决你的问题,请参考以下文章

markdown 公共要点 - 图灵 - 预备工作第4天完成的项目汇编

markdown 公共要点 - 图灵 - 预备工作第3天完成的项目汇编

markdown 公共要点 - 图灵 - 预备工作第2天完成的项目汇编

markdown 公共要点 - 图灵 - 预备工作第1天完成的项目汇编

markdown 公共要点 - 图灵 - 完成装备要点的项目汇编

markdown 公共要点 - 图灵 - 完成专业发展的项目汇编