<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adriana</title>
    <description>The latest articles on DEV Community by Adriana (@allopez2024).</description>
    <link>https://dev.to/allopez2024</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1957084%2Fe81beaaa-4b33-4dfc-ae01-fcf00a41601c.png</url>
      <title>DEV Community: Adriana</title>
      <link>https://dev.to/allopez2024</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/allopez2024"/>
    <language>en</language>
    <item>
      <title>Ruby Hash Notes</title>
      <dc:creator>Adriana</dc:creator>
      <pubDate>Thu, 26 Sep 2024 00:33:17 +0000</pubDate>
      <link>https://dev.to/allopez2024/ruby-hash-notes-n6h</link>
      <guid>https://dev.to/allopez2024/ruby-hash-notes-n6h</guid>
      <description>&lt;p&gt;.store method adds elements to a hash (as opposed to .push with arrays)&lt;br&gt;
  -.store takes two arguments, one label and one value&lt;br&gt;
    i.e person1.store(:first_name, “Adriana”)&lt;br&gt;
    The output will reflect as such: first_name =&amp;gt; Adriana&lt;/p&gt;

&lt;p&gt;Store Shorthand&lt;br&gt;
Input:&lt;br&gt;
person1 = Hash.new&lt;br&gt;
person1[:first_name] = “Adriana”&lt;br&gt;
person1[:last_name] = “Lopez”&lt;br&gt;
person1[:role] = “Student”&lt;/p&gt;

&lt;p&gt;pp person1&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
{:first_name=&amp;gt;”Adriana”, :last_name=&amp;gt;”Lopez”, :role=&amp;gt;”Student”}&lt;/p&gt;

&lt;p&gt;.fetch will retrieve just the value within the dataset&lt;br&gt;
Input:&lt;br&gt;
pp person1.fetch(:first_name)&lt;br&gt;
Output: “Adriana”&lt;/p&gt;

&lt;p&gt;Fetch fallback&lt;br&gt;
To ensure the program doesn’t crash when it tries to retrieve a value that is not there, we can make placeholder values&lt;br&gt;
Input:&lt;br&gt;
person1.store(:first_name, “Adriana”)&lt;br&gt;
pp person1.fetch(:first_name, “None provided”)&lt;br&gt;
pp person1.fetch(:middle_name, “None provided”)&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
“Adriana”&lt;br&gt;
“None provided”&lt;/p&gt;

&lt;p&gt;Fetch Shorthand&lt;br&gt;
Input:&lt;br&gt;
person1.store(:first_name, “Adriana”)&lt;br&gt;
pp person1.fetch(:first_name)&lt;br&gt;
pp person1[:first_name]&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
“Adriana”&lt;br&gt;
“Adriana”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If there is no value when using the [] Notation, the output will result in “Nil”. If there is no value with the standard notation, the output will result in “an error”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hash Literal Notation:&lt;br&gt;
Input:&lt;br&gt;
person1 = { :first_name =&amp;gt; “Adriana”, :last_name =&amp;gt; “Lopez” }&lt;br&gt;
pp person1&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
{:first_name=&amp;gt;”Adriana”, :last_name=&amp;gt;”Lopez”}&lt;/p&gt;

&lt;p&gt;.keys method is used to show all the keys present in a hash. This is returned within an array&lt;br&gt;
Input:&lt;br&gt;
h { “a” =&amp;gt; 1, “b” =&amp;gt; 2, “c” =&amp;gt; 3 }&lt;br&gt;
pp h.keys&lt;br&gt;
pp h.fetch(“b”)&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
[“a”, “b”, “c”]&lt;br&gt;
2&lt;/p&gt;

&lt;p&gt;.key method with arguments is like .fetch in reverse, it searches for the key of a given value &lt;br&gt;
Input:&lt;br&gt;
h { “a” =&amp;gt; 1, “b” =&amp;gt; 2, “c” =&amp;gt; 3 }&lt;br&gt;
pp h.key(2)&lt;br&gt;
pp h.key(5)&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
“b”&lt;br&gt;
nil&lt;/p&gt;

&lt;p&gt;Values within Values&lt;br&gt;
Input:&lt;br&gt;
dictionary = {&lt;br&gt;
:colors =&amp;gt; [“red”, “green”, “blue”]&lt;br&gt;
:person =&amp;gt; {&lt;br&gt;
      :name =&amp;gt; “Adriana Lopez”,&lt;br&gt;
      :age =&amp;gt; 22&lt;br&gt;
   }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;colors_array = dictionary.fetch(:colors)&lt;br&gt;
pp colors_array&lt;br&gt;
pp colors_array.at(1)&lt;br&gt;
pp person_hash = dictionary.fetch(:person)&lt;br&gt;
pp person_hash.fetch(:age)&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
[“red”, “green”, “blue”]&lt;br&gt;
“green”&lt;br&gt;
{ :name =&amp;gt; “Adriana Lopez”, :age =&amp;gt; 22}&lt;br&gt;
22&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Learning Ruby Core Concepts Part 1</title>
      <dc:creator>Adriana</dc:creator>
      <pubDate>Tue, 20 Aug 2024 21:34:03 +0000</pubDate>
      <link>https://dev.to/allopez2024/learning-ruby-core-concepts-part-1-1ek5</link>
      <guid>https://dev.to/allopez2024/learning-ruby-core-concepts-part-1-1ek5</guid>
      <description>&lt;p&gt;Values of Variables Can Be:&lt;br&gt;
Numeric: Any Number/Numerical&lt;br&gt;
Boolean: True or False values (These are written in lowercase! Do not use “” as the computer will assume the value is string instead of Boolean)&lt;br&gt;
String: Uses “” to contain word or phrase values.&lt;/p&gt;

&lt;p&gt;An example of a Numeric Variable Value can be:&lt;br&gt;
my_num = 25 (Note the capitalization, or lack thereof)&lt;br&gt;
You can reassign a variable by using the same structure → my_num = 30&lt;/p&gt;

&lt;p&gt;Ruby Math has multiple operators:&lt;br&gt;
Addition (+)&lt;br&gt;
Subtraction (-)&lt;br&gt;
Multiplication (&lt;em&gt;)&lt;br&gt;
Division (/)&lt;br&gt;
Exponentiation (&lt;/em&gt;&lt;em&gt;) (2&lt;/em&gt;*3 Would have an output of 8 since it reflects 2*2*2)&lt;br&gt;
Modulo (%) (25 % 7 would be 4, since 7 goes into 25 three times with 4 remaining)&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
Input:&lt;br&gt;
sum = 13 + 79&lt;br&gt;
product = 923 * 15&lt;br&gt;
quotient = 13209 / 17&lt;/p&gt;

&lt;p&gt;puts sum&lt;br&gt;
puts product&lt;br&gt;
puts quotient&lt;/p&gt;

&lt;p&gt;Output&lt;br&gt;
392&lt;br&gt;
13845&lt;br&gt;
777&lt;/p&gt;

&lt;p&gt;Puts/Print Command&lt;br&gt;
Print command prints whatever inputs are provided, Puts (For “put string) adds a new (blank) line after the item(s) you want it to print.&lt;/p&gt;

&lt;p&gt;Input: puts “What’s up?”&lt;br&gt;
             print “Hey”&lt;/p&gt;

&lt;p&gt;Output: What’s up?&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Hey
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Ruby is an object oriented language that includes methods that you can write in an editor the interpreter runs said code.&lt;/p&gt;

&lt;p&gt;.length method returns the value of the number of characters, spaces, and numbers of a string&lt;br&gt;
&lt;em&gt;In order to have the console reflect the answer, write the function like so:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Input: puts “I love cake”.length&lt;br&gt;
Output: 11&lt;/p&gt;

&lt;p&gt;.length is helpful for certain value input fields such as a credit card or phone number&lt;/p&gt;

&lt;p&gt;.reverse method returns the string value backwards or in reverse&lt;/p&gt;

&lt;p&gt;Input: puts “Cheese”.reverse&lt;br&gt;
Output: “essehC”&lt;/p&gt;

&lt;p&gt;.reverse is useful for sorting lists from greatest to least or vice versa&lt;/p&gt;

&lt;p&gt;.upcase and .downcase are methods that convert a string to upper case and lower case respectively &lt;/p&gt;

&lt;p&gt;Input: puts “juice”.upcase&lt;br&gt;
Output: JUICE&lt;/p&gt;

&lt;p&gt;Input: puts “JUIce”.downcase&lt;br&gt;
Output: juice&lt;/p&gt;

&lt;p&gt;Single Line Comments&lt;br&gt;
-The ‘#’ sign is used for comments in Ruby. The program will not run anything in this line of text. The comment section comes after the ‘#’ sign and won’t affect the code as long as it is on a  single line&lt;/p&gt;

&lt;p&gt;Input: # I’m a full line comment!&lt;br&gt;
    puts“Eric”.length # I’m a comment, too!&lt;br&gt;
Output: 4&lt;/p&gt;

&lt;p&gt;Multi-Line Comments&lt;br&gt;
To start a multi line comment, use ‘=begin’ and end with ‘=end’&lt;br&gt;
=begin&lt;br&gt;
I’m a comment!&lt;br&gt;
I don’t need any # symbols.&lt;br&gt;
=end&lt;/p&gt;

&lt;p&gt;In Ruby, you can write each method on a separate line or chained together: &lt;br&gt;
( variable.method1.method2.method3)&lt;br&gt;
Remember to include ‘puts’ for the methods to see the result!&lt;/p&gt;

&lt;p&gt;Input: name = “Adriana”&lt;br&gt;
             puts name.downcase.reverse.upcase&lt;br&gt;
Output: ANAIRDA&lt;/p&gt;

&lt;p&gt;.gets is a method that gets input from the user. When the input is received, the output automatically adds a blank (new) line, .chomp removes that extra line, but the code will still work without using the method. &lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
prints = “What’s your first name?”&lt;br&gt;
first_name = gets.chomp&lt;br&gt;
Output:&lt;br&gt;
    What’s your first name? (You can type a response into the terminal code *NOT the editor)&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
print "What's your first name? "&lt;br&gt;
first_name = gets.chomp.capitalize!&lt;/p&gt;

&lt;p&gt;print "What's your last name? "&lt;br&gt;
last_name = gets.chomp.capitalize!&lt;/p&gt;

&lt;p&gt;print "What city are you from? "&lt;br&gt;
city = gets.chomp.capitalize!&lt;/p&gt;

&lt;p&gt;print "What state or province are you from? "&lt;br&gt;
state = gets.chomp.upcase!&lt;/p&gt;

&lt;p&gt;puts "Your name is #{first_name} #{last_name} and you're from #{city}, #{state}!"&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
What's your first name? adriana&lt;br&gt;
What's your last name? lopez&lt;br&gt;
What city are you from? chicago&lt;br&gt;
What state or province are you from? il&lt;br&gt;
Your name is Adriana Lopez and you're from Chicago, IL!&lt;/p&gt;

&lt;p&gt;‘If’ statements, evaluate a value to be either true or false (not to be confused with Boolean). If the expression is true Ruby executes the block of code. If the expression is false, it moves on to execute the next block of code. ‘If’ statements always finish with ‘end’&lt;br&gt;
‘else’ is the next condition if the previous ‘if’ statement does not execute as ‘true’&lt;br&gt;
‘elsif ’ works in a similar way to ‘else’&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
if 1 &amp;gt; 3&lt;br&gt;
prints “True”&lt;br&gt;
else&lt;br&gt;
Prints “False”&lt;br&gt;
end&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
False&lt;/p&gt;

&lt;p&gt;‘==’ statement checks to see if variables previously defined are equal to each other (true). To check if values are not equal to each other (false) then use ‘!==’ &lt;br&gt;
X =2&lt;br&gt;
Y = 2&lt;br&gt;
if x==y&lt;br&gt;
prints “X is equal to Y”&lt;br&gt;
end&lt;/p&gt;

&lt;p&gt;Comparison Operators:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Less than&lt;br&gt;
=&amp;gt; Less than or equal to&lt;br&gt;
&amp;lt; Greater than&lt;br&gt;
&amp;lt;= Greater than or equal to&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;test_one = 17 &amp;gt; 10&lt;/p&gt;

&lt;p&gt;Logical/Boolean Operators&lt;br&gt;
The Boolean operator and (‘&amp;amp;&amp;amp;’) only results in ‘true’ if both sides of an expression are true&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
true &amp;amp;&amp;amp; true&lt;br&gt;
true &amp;amp;&amp;amp; false&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
True &lt;br&gt;
False&lt;/p&gt;

&lt;p&gt;The or (||) operator is an inclusive or because it evaluates to true when one or both of the expression are true&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
true || true &lt;br&gt;
true || false&lt;br&gt;
false || true&lt;br&gt;
false || false&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
True&lt;br&gt;
True&lt;br&gt;
True&lt;br&gt;
False&lt;/p&gt;

&lt;p&gt;The boolean operator not (‘!’) makes true values false, and false values true&lt;br&gt;
Example Goes Here&lt;/p&gt;

&lt;p&gt;You can combine Boolean Operators in an expression:&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
boolean_1 (3 &amp;lt; 4 || false &amp;amp;&amp;amp; (false || true)&lt;br&gt;
Result:&lt;br&gt;
boolean_1 = true&lt;/p&gt;

&lt;p&gt;Operator Example:&lt;br&gt;
daytime = false&lt;br&gt;
print “It is nighttime” unless daytime&lt;/p&gt;

&lt;p&gt;User Input:&lt;br&gt;
prints “How old are You?”&lt;br&gt;
user_input = gets.chomp&lt;/p&gt;

&lt;p&gt;This allows a user to type a response into the terminal for the system to process&lt;/p&gt;

&lt;p&gt;The ‘include?’ method checks to see if a value is true (or false) based off of a condition.&lt;br&gt;
(i.e. if user_input.include? “hello”) This allows a if/end statement that can access string variables (including sole letters, words, or phrases)&lt;/p&gt;

&lt;p&gt;The ‘.gsub!’ method (Global substitution) will replace part of a string with something else&lt;br&gt;
(i.e. user_input.gsub!(/hi/, “hello”) This will replace all strings that say ‘hi’ with ‘hello’&lt;/p&gt;

&lt;p&gt;print "Pleathe enter a thtring: "&lt;br&gt;
user_input = gets.chomp&lt;br&gt;
user_input.downcase!&lt;/p&gt;

&lt;p&gt;if user_input.include? "s"&lt;br&gt;
  user_input.gsub!(/s/, "th")&lt;br&gt;
else&lt;br&gt;
print "nothing here"&lt;br&gt;
end&lt;br&gt;
puts "I am, #{user_input}!"&lt;/p&gt;

&lt;p&gt;This code changes an ‘s’s’ to ‘th’ and relays the message “I am__” with the user’s input (including modifications → downcase and ‘th’)&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
