<commit_before><!Doctype html>
<html>
  <head>
    <h2>The Ruby .map Method</h2>

  <link rel="stylesheet" type="text/css" href="/unit1_week1/stylesheets/stylesheet_for_blog.css">
  </head>
    <body>

    <h4>What's one of the most useful, important, and common methods in Ruby? Let's MAP out the answer (get it, get it?).</h4>  

    <section>
      <p>The definiton of Ruby's .map method is as follows: </p>

      the .each method will iterate through
# the array/hash and alter each element one at a time, but it will RETURN THE ORIGINAL ARRAY/HASH.
# Meaning, it will not return the result of what was altered. The .map method, on the other
# hand, builds a new array of the RESULTS FROM ITERATING OVER EACH ELEMENT. For example,
# if you have [1, 2, 3].each { |x| x + 1 } it will add 1 to each element and then throw those
# results away, only to return [1, 2, 3]. But if you do [1, 2, 3].map { |i| i + 1 } the return
# value is [2, 3, 4]. FUCK YES KNOWLEDGE. 

Real example:

def separate_comma(num)
  num_array = num.to_s.chars.reverse
  final_num = num_array.each_slice(3).map {|x| x.join }
  final_num.join(",").reverse
end

  </section>
  <a href="unit1_week1/index.html" style="text-align:center">Home</a>
  </body>
</html>


<commit_msg>added week 4 tech blog<commit_after><!Doctype html>
<html>
  <head>
    <h2>The Ruby .map Method</h2>

  <link rel="stylesheet" type="text/css" href="/unit1_week1/stylesheets/stylesheet_for_blog.css">
  </head>
    <body>

    <h4>What's one of the most useful, important, and common methods in Ruby? Let's MAP out the answer (get it, get it?).</h4>  

    <section>
      <p>The definiton of Ruby's .map method is as follows: </p>

      the .each method will iterate through
# the array/hash and alter each element one at a time, but it will RETURN THE ORIGINAL ARRAY/HASH.
# Meaning, it will not return the result of what was altered. The .map method, on the other
# hand, builds a new array of the RESULTS FROM ITERATING OVER EACH ELEMENT. For example,
# if you have [1, 2, 3].each { |x| x + 1 } it will add 1 to each element and then throw those
# results away, only to return [1, 2, 3]. But if you do [1, 2, 3].map { |i| i + 1 } the return
# value is [2, 3, 4]. FUCK YES KNOWLEDGE. 

Real example:

def separate_comma(num)
  num_array = num.to_s.chars.reverse
  final_num = num_array.each_slice(3).map {|x| x.join }
  final_num.join(",").reverse
end

  <a href="lrakhman.github.io" style="text-align:center">Home</a>


  </section>
  
  </body>
</html>



{'fraction_non_alphanumeric': 0.12738853503184713, 'fraction_numerical': 0.018710191082802547, 'mean_word_length': 3.4242957746478875, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4723936', 'n_tokens_mistral': 940, 'n_tokens_neox': 872, 'n_words': 338}