<?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: Yandri Sanchez</title>
    <description>The latest articles on DEV Community by Yandri Sanchez (@ysanchez3d).</description>
    <link>https://dev.to/ysanchez3d</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%2F621420%2F513abde2-5616-4512-a4f3-25ec14e7676c.jpeg</url>
      <title>DEV Community: Yandri Sanchez</title>
      <link>https://dev.to/ysanchez3d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ysanchez3d"/>
    <language>en</language>
    <item>
      <title>&gt;&lt;s&amp;#99;ript&gt;alert("You've been pwned!");&lt;/s&amp;#99;ript&gt;</title>
      <dc:creator>Yandri Sanchez</dc:creator>
      <pubDate>Sun, 27 Jul 2025 19:19:05 +0000</pubDate>
      <link>https://dev.to/ysanchez3d/s99riptalertyouve-been-pwneds99ript-e8j</link>
      <guid>https://dev.to/ysanchez3d/s99riptalertyouve-been-pwneds99ript-e8j</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;alert("You've been pwned!");&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>security</category>
      <category>html</category>
    </item>
    <item>
      <title>test1</title>
      <dc:creator>Yandri Sanchez</dc:creator>
      <pubDate>Sun, 27 Jul 2025 19:17:35 +0000</pubDate>
      <link>https://dev.to/ysanchez3d/test1-3k18</link>
      <guid>https://dev.to/ysanchez3d/test1-3k18</guid>
      <description>&lt;blockquote&gt;
alert("You've been pwned!");
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>snippet</category>
    </item>
    <item>
      <title>Understanding Blocks &amp; Procs in Ruby</title>
      <dc:creator>Yandri Sanchez</dc:creator>
      <pubDate>Tue, 29 Jun 2021 22:02:50 +0000</pubDate>
      <link>https://dev.to/ysanchez3d/blocks-and-procs-in-ruby-46p5</link>
      <guid>https://dev.to/ysanchez3d/blocks-and-procs-in-ruby-46p5</guid>
      <description>&lt;h2&gt;
  
  
  Blocks
&lt;/h2&gt;

&lt;p&gt;Blocks in Ruby are fairly easy to understand. A block simply contains chunks of code inside and can be passed into methods. If you're familiar with javascript, then a block is equivalent to an anonymous function.&lt;/p&gt;

&lt;p&gt;Blocks can be created in two ways, using &lt;code&gt;{..}&lt;/code&gt; or the &lt;code&gt;do..end&lt;/code&gt; syntax.&lt;br&gt;
&lt;code&gt;{..}&lt;/code&gt; is used for single line blocks, while &lt;code&gt;do..end&lt;/code&gt; syntax is used to encapsulate multiple lines of code.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Unlike methods, you should &lt;strong&gt;never&lt;/strong&gt; use the &lt;code&gt;return&lt;/code&gt; keyword inside a block unless you have a really good reason for it. Lets explore why..&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You see, the &lt;code&gt;return&lt;/code&gt; keyword always belong to methods, so in the second example when &lt;code&gt;words.map&lt;/code&gt; iterates over the array, it instantly returns the first word it encounters and &lt;code&gt;yell_words&lt;/code&gt; ends immediately with the output of "LION!" which is not at all what we were expecting. This is a common pitfall for programming newbies, and I surely have been a victim numerous times.&lt;br&gt;&lt;br&gt;
The last thing I want to point out is a shorthand for writing methods that only take 'one' argument that calls a single method. Lets take a peek:&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a id="shorten-method"&gt;&lt;/a&gt;&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;/h3&gt;

&lt;p&gt;Lets break this down to understand what all of it means. First, we are calling &lt;code&gt;Array.select&lt;/code&gt; and passing in the argument &lt;code&gt;&amp;amp;:odd?&lt;/code&gt;. The &lt;code&gt;:odd?&lt;/code&gt; part is just a symbol that refers to the &lt;code&gt;Integer#odd?&lt;/code&gt; &lt;em&gt;'method'&lt;/em&gt;, which will be called on every element of the array, and &lt;code&gt;&amp;amp;&lt;/code&gt; is used to convert the &lt;em&gt;'method'&lt;/em&gt; into a Proc(a normal Ruby object) that can be passed into &lt;code&gt;select&lt;/code&gt;.&lt;br&gt;
In Ruby it's not possible to pass methods into other methods so we must convert them to Procs in order to do that.&lt;/p&gt;
&lt;h2&gt;
  
  
  Procs
&lt;/h2&gt;

&lt;p&gt;A proc is a ruby object that contains a block inside. Through procs, we are able to pass blocks of code around or even save them to a variable. See example below:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now lets see how we can pass a proc into other methods:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Notice that we can really alter the behavior of methods by passing in procs that do different things depending on our needs. That's great and all, but can we shorten this a bit? Yes we can!&lt;br&gt;
Ruby allow us to automatically convert blocks into procs. Remember our old friend &lt;code&gt;&amp;amp;&lt;/code&gt; from the block's example, earlier? Lets see how it works:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It's important to note that since we added &lt;code&gt;&amp;amp;prc&lt;/code&gt; as the third argument of the method, &lt;code&gt;combine_and_proc&lt;/code&gt; must always be called with a block or it will throw an error. The block will be taken by the &lt;code&gt;&amp;amp;prc&lt;/code&gt; argument, and &lt;code&gt;&amp;amp;&lt;/code&gt; will turn the block into a proc. Now when we call &lt;code&gt;puts prc.call(word)&lt;/code&gt; inside &lt;code&gt;combine_and_proc&lt;/code&gt; there will be no errors because &lt;code&gt;prc&lt;/code&gt; was turned into a proc by Ruby automatically.&lt;/p&gt;

&lt;p&gt;To wrap up, i'd like to mention one last thing that our friend &lt;code&gt;&amp;amp;&lt;/code&gt; can do for us, and that is to turn a proc into a block. Yes, it might sound confusing but it works both ways. Lets take a look:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;From the previous example we can gather that &lt;code&gt;select&lt;/code&gt; takes in a block as its last argument. Then, we created the proc &lt;code&gt;odds&lt;/code&gt; and passed it like this &lt;code&gt;[1,2,3].select(odds)&lt;/code&gt; and so we get an error because &lt;code&gt;odds&lt;/code&gt; is a proc and &lt;code&gt;select&lt;/code&gt; is expecting a block. So the correct way would be to call select with &lt;code&gt;&amp;amp;odds)&lt;/code&gt; because &lt;code&gt;&amp;amp;&lt;/code&gt; will turn the proc into a block right before giving it to the &lt;code&gt;select&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;I hope these examples were helpful, and please feel free to alert me of any corrections to the article.&lt;/p&gt;

&lt;p&gt;Happy coding  😃&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>programming</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
