<?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: TinyNight(JP)</title>
    <description>The latest articles on DEV Community by TinyNight(JP) (@midpolarnight).</description>
    <link>https://dev.to/midpolarnight</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4043448%2Ff739265f-edb4-44ee-a35a-88e5ddaac5c1.png</url>
      <title>DEV Community: TinyNight(JP)</title>
      <link>https://dev.to/midpolarnight</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/midpolarnight"/>
    <language>en</language>
    <item>
      <title>How to Remember Namespaces</title>
      <dc:creator>TinyNight(JP)</dc:creator>
      <pubDate>Mon, 03 Aug 2026 03:14:30 +0000</pubDate>
      <link>https://dev.to/midpolarnight/how-to-remember-namespaces-106g</link>
      <guid>https://dev.to/midpolarnight/how-to-remember-namespaces-106g</guid>
      <description>&lt;p&gt;I often see people using the term "namespace" incorrectly. Even when explanations of what a namespace is are presented, they only go as far as describing its function, neglecting to properly define the name "namespace" itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Definition of the Namespace
&lt;/h2&gt;

&lt;p&gt;A namespace is literally the &lt;strong&gt;space to which a name belongs&lt;/strong&gt;. If we were to classify the term namespace, it would be a specification (concept), not a tool.&lt;/p&gt;

&lt;p&gt;In namespaces, the higher level is represented as &lt;code&gt;outer&lt;/code&gt; and the lower level as &lt;code&gt;inner&lt;/code&gt;. In terms of class structure, this corresponds to outer classes and inner classes. In other words, to explain it from a different perspective, it looks like this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Representation of namespaces from the outer perspective
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Build namespaces (best)&lt;/li&gt;
&lt;li&gt;Define namespaces (to fit many programming language implementations)&lt;/li&gt;
&lt;li&gt;Open namespaces (such as Ruby's &lt;code&gt;class definition&lt;/code&gt; and &lt;code&gt;module definition&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Create namespaces (such as the pseudo-namespace hack in older JavaScript)&lt;/li&gt;
&lt;li&gt;Declare namespaces (such as the &lt;code&gt;package&lt;/code&gt; declaration in Java or the &lt;code&gt;namespace&lt;/code&gt; declaration in PHP)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Representation of namespaces from the inner perspective
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Belong to a namespace (best)&lt;/li&gt;
&lt;li&gt;Entering the namespace (This is entirely from an &lt;code&gt;inner&lt;/code&gt; perspective, so it might feel out of place depending on the context)&lt;/li&gt;
&lt;li&gt;Be included in the namespace (this is a reasonable explanation if explained objectively).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Incorrect expression
&lt;/h3&gt;

&lt;p&gt;From the definition above, it is clear that the following expressions are incorrect.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add/Paste a namespace (the expression "add/paste a space" is grammatically incorrect).&lt;/li&gt;
&lt;li&gt;Use namespaces (not to the point of being completely broken, but treating namespaces as a tool)&lt;/li&gt;
&lt;li&gt;Separate/Cut namespaces (While "Separated by namespaces" is understandable, "separate/cut" can be misleading)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Meaning of "Name" in Namespace
&lt;/h2&gt;

&lt;p&gt;The "names" referred to here can be class names, module names, or package names. What they represent varies depending on the language that implements namespaces.&lt;/p&gt;

&lt;p&gt;For example, in Ruby, it refers to constant names. In Ruby, class names (module names) are also constants, so &lt;code&gt;outer&lt;/code&gt; refers to class name constants, and &lt;code&gt;inner&lt;/code&gt; includes both general constants and class name constants. Since general constants cannot be &lt;code&gt;outer&lt;/code&gt;, a structure is created where class name constants can be nested, but general constants cannot.&lt;/p&gt;

&lt;h2&gt;
  
  
  An easy-to-understand metaphor
&lt;/h2&gt;

&lt;p&gt;Belonging to a namespace means that &lt;code&gt;inner&lt;/code&gt; moves to a town called &lt;code&gt;outer&lt;/code&gt;, and &lt;code&gt;inner&lt;/code&gt; is included in &lt;code&gt;outer&lt;/code&gt;'s address book. Problems arise if an entity claims an address in another town without actually being in it (this example is easily illustrated by Ruby's constants &lt;sup id="fnref1"&gt;1&lt;/sup&gt;).&lt;/p&gt;

&lt;p&gt;Alternatively, a tenant named &lt;code&gt;inner&lt;/code&gt; would enter into a lease agreement with a multi-tenant building called &lt;code&gt;outer&lt;/code&gt;, and &lt;code&gt;inner&lt;/code&gt; would occupy a floor within that building. As a result, &lt;code&gt;inner&lt;/code&gt;'s address would be "&lt;code&gt;inner&lt;/code&gt; tenant inside the &lt;code&gt;outer&lt;/code&gt; building".&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;Ruby constants have a reference path that combines a lexical namespace and inheritance. When moving and referencing (physical nesting), you can reference the constants of the outer namespace, but when calling out the address from outside (adding a namespace prefix), you cannot reference the constants of the outer namespace.&amp;nbsp;↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>programming</category>
      <category>learning</category>
      <category>tutorial</category>
      <category>ruby</category>
    </item>
    <item>
      <title>[Ruby] The True Value of Flow Control Operators</title>
      <dc:creator>TinyNight(JP)</dc:creator>
      <pubDate>Fri, 31 Jul 2026 16:09:37 +0000</pubDate>
      <link>https://dev.to/midpolarnight/ruby-the-true-value-of-flow-control-operators-115l</link>
      <guid>https://dev.to/midpolarnight/ruby-the-true-value-of-flow-control-operators-115l</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Ruby has four types of logical operators: &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; / &lt;code&gt;||&lt;/code&gt; / &lt;code&gt;and&lt;/code&gt; / &lt;code&gt;or&lt;/code&gt;, each with a different precedence.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; / &lt;code&gt;||&lt;/code&gt; have higher precedence as operators, with &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; taking precedence over &lt;code&gt;||&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;and&lt;/code&gt; / &lt;code&gt;or&lt;/code&gt; have low operator precedence, and there is no priority between them. In other words, they are evaluated from left to right.&lt;/p&gt;

&lt;p&gt;These are sometimes described as being "also usable for flow control," but that statement is incorrect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;and&lt;/code&gt; / &lt;code&gt;or&lt;/code&gt; are extremely powerful flow control operators.&lt;/strong&gt; It's not an exaggeration to say they were implemented specifically for flow control (more on this later).&lt;/p&gt;

&lt;p&gt;The suggestion that these should be used for flow control has been made for a long time, by "Ruby Good Idiom" and others, but the problem is that even those articles themselves misuse them, and as a result, they haven't become widespread. Even the official references downplay their usefulness.&lt;/p&gt;

&lt;p&gt;In this article, I will explain these points in detail and discuss the true value of flow control operators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flow control syntax
&lt;/h2&gt;

&lt;p&gt;As the name suggests, flow control operators are operators that perform "flow control." They combine the functions of controlling the flow and returning a value as an operator. The reason why &lt;code&gt;and&lt;/code&gt; / &lt;code&gt;or&lt;/code&gt; have no precedence is because they are operators for flow control. In other words, flow control operators can be rephrased as operators that &lt;strong&gt;control both the flow and the return value&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Since it is used for flow control, its essence is no different from control structures. In other words, using it by grouping it on a single line and nesting it is an incorrect usage that significantly reduces code readability and clarity of control flow.&lt;/p&gt;

&lt;p&gt;If used correctly, it's best to place it at the end of a line, followed by a line break. Simply adhering to this rule alone is quite effective.&lt;/p&gt;

&lt;p&gt;While the aforementioned "Ruby Good Idiom" uses this operator for exception handling, this is incorrect. This is because an exception is fundamentally something that goes outside the flow's control. If you're going to throw an exception, you should either throw it before entering flow control or after flow control, using a guard clause.&lt;/p&gt;

&lt;h3&gt;
  
  
  Examples of common control statements
&lt;/h3&gt;

&lt;p&gt;When controlling the return value using common control statements, the code would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_method&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="c1"&gt;# Conditional comparison for calling a function.&lt;/span&gt;
    &lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# The return value of the function will be the return value of test_method.&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="kp"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;# If the condition is not met, test_method will return false.&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="c1"&gt;# If there is no else clause, the return value of test_method will be nil.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's easy to understand, but it's redundant. It doesn't have a trace of idiomatic Ruby.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example using logical operators
&lt;/h3&gt;

&lt;p&gt;When controlling return values using logical operators, the following type of code is common.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_method&lt;/span&gt;
  &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;# Returns false when the previous conditional comparison becomes false.&lt;/span&gt;
  &lt;span class="c1"&gt;# Otherwise, the return value of the function will be the return value of test_method.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While it's very compact, the code mixes two flows—conditional comparison and function call—into a single line, resulting in extremely poor code readability and clarity of control flow. This is a bad example of compressed notation, which is often seen in other languages ​​as well. It goes against Matz's philosophy.&lt;br&gt;
　&lt;/p&gt;
&lt;h3&gt;
  
  
  Example using flow control operators
&lt;/h3&gt;

&lt;p&gt;When controlling the return value using flow control operators, the code would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_method&lt;/span&gt;
  &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="c1"&gt;# If the condition is met, proceed to the next step in the flow.&lt;/span&gt;
                      &lt;span class="c1"&gt;# If not satisfied, return false and exit the flow.&lt;/span&gt;
    &lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# The return value of the function will be the return value of test_method.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following the rules of flow control syntax, a flow control operator is used at the end of the line to create a new line.&lt;/p&gt;

&lt;p&gt;The two flows—conditional comparison and function call—are visually separated, resulting in high code readability and clarity of control flow. Furthermore, there's no redundancy like in control statements. This demonstrates the extremely powerful syntax of Ruby's flow control operators.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ruby method specifications
&lt;/h2&gt;

&lt;p&gt;Ruby has a great many methods that return either a &lt;code&gt;value&lt;/code&gt; or &lt;code&gt;nil&lt;/code&gt;. This is intentional. In Ruby, a &lt;code&gt;value&lt;/code&gt; (an object other than &lt;code&gt;nil&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;) is treated as &lt;code&gt;true&lt;/code&gt;, and &lt;code&gt;nil&lt;/code&gt; is treated as &lt;code&gt;false&lt;/code&gt;. In other words, they can be evaluated with flow control operators. It can be said that this is a specification designed to control the flow and return value using flow control operators. They should be appropriately called &lt;strong&gt;flow control methods&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sample code is shown below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example of controlling flow and return value with flow control methods
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;find_employee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="no"&gt;OFFICERS_LIST&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt;
  &lt;span class="no"&gt;EMPLOYEES_LIST&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt;
  &lt;span class="no"&gt;SECONDED_EMPLOYEES_LIST&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt;
  &lt;span class="kp"&gt;nil&lt;/span&gt; &lt;span class="c1"&gt;# Does not exist.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code is a method that searches three lists in order from top to bottom and returns the employee whose name matches. The flow control method &lt;code&gt;find&lt;/code&gt; returns &lt;code&gt;value (truthy)&lt;/code&gt; if the employee is found, so the flow control operator &lt;code&gt;or&lt;/code&gt; stops there, and the found value becomes the return value of the method. If it is not found, the flow moves to the next list, and if it is not found at all, it returns &lt;code&gt;nil&lt;/code&gt; to indicate that it was not found (it also behaves as a flow control method itself).&lt;/p&gt;

&lt;p&gt;The flow control operators and methods work together beautifully, highlighting a simple flow structure completely free of unnecessary code. This is the world Ruby aimed for. This is the very essence of Matz's philosophy.&lt;/p&gt;

&lt;p&gt;If you're concerned about the duplication in the name check part of the above code, you can simply convert the closure into a Proc and pass that instead. That's a very Ruby-like solution, after all.&lt;/p&gt;

&lt;p&gt;Some of you might be thinking, "Isn't the final &lt;code&gt;nil&lt;/code&gt; unnecessary?" And you'd be right, because the final &lt;code&gt;find&lt;/code&gt; also returns either a &lt;code&gt;value&lt;/code&gt; or &lt;code&gt;nil&lt;/code&gt;, so the result wouldn't change even if it were omitted. However, it's necessary for visualizing the flow. It would be a waste to enhance the clarity of control flow with flow control operators only to hide it at the end. That's why I put &lt;code&gt;nil&lt;/code&gt; here.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use &lt;code&gt;and&lt;/code&gt; / &lt;code&gt;or&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;As in the first flow control example, &lt;code&gt;and&lt;/code&gt; serves to connect the conditional expression with the next flow. It's helpful to remember that it's an operator that advances the flow &lt;strong&gt;if the condition is met&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;or&lt;/code&gt; serves to connect flow control methods, as in the last example. It's helpful to remember that it's an operator that advances the flow if &lt;strong&gt;no value is found&lt;/strong&gt; (if &lt;code&gt;nil&lt;/code&gt; is returned) by the flow control method.&lt;/p&gt;

&lt;h2&gt;
  
  
  summary
&lt;/h2&gt;

&lt;p&gt;I hope this article has helped you reaffirm just how beautifully designed Ruby is. The elegant flow control using flow control operators, and the overwhelming readability when used in conjunction with flow control methods—Ruby is a human-centered language designed to make programming enjoyable.&lt;/p&gt;

&lt;p&gt;Along with the previously posted guide on "how to correctly remember &lt;code&gt;unless&lt;/code&gt; and &lt;code&gt;until&lt;/code&gt;", I hope many Rubyists will find this useful.&lt;/p&gt;

&lt;p&gt;Related: &lt;a href="https://dev.to/midpolarnight/ruby-how-to-truly-understand-unless-and-until-3kn1"&gt;[Ruby] How to Truly Understand unless and until&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  bonus
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Basic Guidelines for Flow Partitioning
&lt;/h3&gt;

&lt;p&gt;As some of you may have noticed from this article and the sample code in the aforementioned &lt;code&gt;unless&lt;/code&gt; article, negation operators (&lt;code&gt;!&lt;/code&gt; and &lt;code&gt;not&lt;/code&gt;) are not used at all, except in the bad examples. This is not because I chose those conditions and only used them. In fact, the inclusion of negation operators in conditional expressions is evidence that the flow has not been properly divided.&lt;/p&gt;

&lt;p&gt;A clear code example is shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;empty?&lt;/span&gt; &lt;span class="c1"&gt;# Commonly seen guard clause.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example above is a typical guard clause that any Ruby programmer has probably written at some point. However, upon closer inspection, it contains two interwoven flows. If these flows are properly separated, it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;    &lt;span class="c1"&gt;# Whitelist (except nil).&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;empty?&lt;/span&gt; &lt;span class="c1"&gt;# Blacklist If the content is empty, do not allow it.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If flows are not mixed in this way, negation operators will basically not be mixed in. Therefore, if a conditional expression contains a negation operator, you should first check whether flows are mixed in. If conditional expressions and function calls are mixed in, as in this article, or if the whitelist and blacklist guard clauses are combined into a single guard clause, as in the example above, simply separating the flows in that section should dramatically improve the readability of the code and clarity of control flow.&lt;/p&gt;

&lt;p&gt;Of course, it's impossible to eliminate them completely. For example, there are cases like &lt;code&gt;!ary.include?(0)&lt;/code&gt; where there's nothing you can do. Implementing an &lt;code&gt;exclude?&lt;/code&gt; method is an option, but this level of negation doesn't significantly reduce readability, so it's acceptable. The important thing isn't to eliminate negation operators. It's simply about improving readability and clarity of control flow through proper flow division.&lt;/p&gt;

&lt;h3&gt;
  
  
  Your past self is a stranger
&lt;/h3&gt;

&lt;p&gt;This emphasis on readability might sometimes come across as uncouth or overly intrusive. However, those who have been programming for a long time will likely understand the experience of looking at their own code years or months later, after being away from the field for a while, and finding it incomprehensible—like looking at spaghetti code written by someone else.&lt;/p&gt;

&lt;p&gt;Adding annotations with comments is fine, but doing so for every single line of code is redundant and looks bad. It's far better to separate the flow and design the code to speak for itself.&lt;/p&gt;

&lt;p&gt;This is so important I'll say it twice: "&lt;strong&gt;Your past self is a stranger&lt;/strong&gt;." Paradoxically, this means your future self is also a stranger. Even if you're developing a project on your own, or perhaps especially because you're developing it on your own, write code that won't confuse your future self. Because the consequences of that will undoubtedly fall back on you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/midpolarnight/ruby-how-to-truly-understand-unless-and-until-3kn1"&gt;[Ruby] How to Truly Understand unless and until&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ruby</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>coding</category>
    </item>
    <item>
      <title>[Ruby] How to Truly Understand unless and until</title>
      <dc:creator>TinyNight(JP)</dc:creator>
      <pubDate>Mon, 27 Jul 2026 06:13:06 +0000</pubDate>
      <link>https://dev.to/midpolarnight/ruby-how-to-truly-understand-unless-and-until-3kn1</link>
      <guid>https://dev.to/midpolarnight/ruby-how-to-truly-understand-unless-and-until-3kn1</guid>
      <description>&lt;p&gt;I frequently see comments that 'unless' and 'until' are difficult to understand.&lt;br&gt;
I've also heard that it's prohibited in tools like &lt;code&gt;rubocop&lt;/code&gt;.&lt;br&gt;
This is a fundamentally flawed way of thinking about &lt;code&gt;unless&lt;/code&gt; and &lt;code&gt;until&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As a basic principle, abandon the idea of ​​"if it becomes &lt;code&gt;false&lt;/code&gt;".&lt;br&gt;
The basic principle is to remember what happens when the condition evaluates to &lt;code&gt;true&lt;/code&gt;, and you won't get confused.&lt;/p&gt;
&lt;h2&gt;
  
  
  unless
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Think of &lt;code&gt;unless&lt;/code&gt; as an expression that will not be executed if the condition is met.
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;     &lt;span class="c1"&gt;# If a &amp;amp;&amp;amp; b is satisfied, execute the left side.&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="c1"&gt;# If a &amp;amp;&amp;amp; b is satisfied, do not execute the left side.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  When combined with return (guard clause), it should be considered a condition for proceeding with the process.
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;     &lt;span class="c1"&gt;# Terminate processing if (a &amp;amp;&amp;amp; b) is satisfied.&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="c1"&gt;# Proceed with processing if (a &amp;amp;&amp;amp; b) is satisfied.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;When using them as guard clauses, remember the following: The two have distinctly different roles.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Keywords&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;return &lt;strong&gt;&lt;code&gt;if&lt;/code&gt;&lt;/strong&gt; expression&lt;/td&gt;
&lt;td&gt;blacklist&lt;/td&gt;
&lt;td&gt;Terminate processing if the expression is satisfied&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;return &lt;strong&gt;&lt;code&gt;unless&lt;/code&gt;&lt;/strong&gt; expression&lt;/td&gt;
&lt;td&gt;whitelist&lt;/td&gt;
&lt;td&gt;Proceed with processing if the expression is satisfied&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To differentiate their use, any judgment formulas that involve both should be separated.&lt;br&gt;
An example is shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;gagazet_gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yevonite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# case 1&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Kimahri&lt;/span&gt;
  &lt;span class="c1"&gt;# Blocks only Kimahri. This allows unauthorized people to pass through.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;gagazet_gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yevonite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# case 2&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Summoner&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Guardian&lt;/span&gt;
  &lt;span class="c1"&gt;# Summoners and Guardians are allowed through. This means Kimahri can also get through.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;gagazet_gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yevonite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Bad case&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Kimahri&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;Summoner&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;Guardian&lt;/span&gt;
    &lt;span class="c1"&gt;# "No passing if you're Kimahri, and also if you're not a summoner, and also if..."&lt;/span&gt;
    &lt;span class="c1"&gt;# Not Biran!&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;gagazet_gate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yevonite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Best case&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Summoner&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Guardian&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;yevonite&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;Kimahri&lt;/span&gt;
  &lt;span class="c1"&gt;# Summoner may pass. Guardians may pass. Kimahri not pass!&lt;/span&gt;
  &lt;span class="c1"&gt;# Since these two guard clauses serve diametrically opposite purposes, they should be used separately.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  until
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The &lt;code&gt;until&lt;/code&gt; statement can be thought of as a condition that exits the loop when it becomes true.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="c1"&gt;# Loops while i is less than 10&lt;/span&gt;
&lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;until&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="c1"&gt;# Exit the loop when i becomes 0 or less&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, the following example is easy to understand. The formula is also elegant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_a&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shift&lt;/span&gt; &lt;span class="k"&gt;until&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;empty?&lt;/span&gt; &lt;span class="c1"&gt;# Exit the loop when a becomes empty&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;While it's often suggested that &lt;code&gt;unless&lt;/code&gt; be replaced with &lt;code&gt;if not&lt;/code&gt;, that suggestion is based on a flawed premise.&lt;br&gt;
&lt;code&gt;unless&lt;/code&gt; and &lt;code&gt;until&lt;/code&gt; are not constructs that reverse the evaluation of &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; conditional expressions. Rather, they are constructs that "reverse the behavior" of a conditional expression.&lt;/p&gt;

&lt;p&gt;Furthermore, &lt;code&gt;until&lt;/code&gt; is actually more suitable for loop control than while because it clarifies the goal.&lt;br&gt;
&lt;code&gt;until&lt;/code&gt; is the true ace among loop constructs. It is definitely not just a variation of &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>ruby</category>
      <category>coding</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Inference: The Essence of Psychological Burden</title>
      <dc:creator>TinyNight(JP)</dc:creator>
      <pubDate>Thu, 23 Jul 2026 10:39:32 +0000</pubDate>
      <link>https://dev.to/midpolarnight/tui-lun-xin-li-de-fu-he-nozheng-ti-j73</link>
      <guid>https://dev.to/midpolarnight/tui-lun-xin-li-de-fu-he-nozheng-ti-j73</guid>
      <description>&lt;p&gt;Translated from Japanese via Google Translate. Original text included at the bottom for reference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Humans calculate psychological distance using the Pythagorean theorem, and psychological load is proportional to the computational effort involved.
&lt;/h2&gt;

&lt;p&gt;Based on this premise, we can reason through and resolve questions often raised in various fields.&lt;/p&gt;

&lt;p&gt;To proceed with this line of reasoning, we define the computational models for measuring psychological distance as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pythagorean calculation = A simple calculation to measure the "distance from the origin" using the Pythagorean theorem.&lt;/li&gt;
&lt;li&gt;Euclidean calculation = A computationally intensive calculation that performs the Pythagorean calculation multiple times to measure the "distance between multiple coordinates."&lt;/li&gt;
&lt;/ul&gt;

&lt;dl&gt;
&lt;dt&gt;The American World of Objective Perspective&lt;/dt&gt;
&lt;dd&gt;A society that calculates Euclidean distances relative to countless others.&lt;/dd&gt;
&lt;dd&gt;From this perspective, one must locate oneself within a vast space, necessitating strong self-assertion—even at the cost of significant resources. Failure to do so risks literally losing sight of oneself amidst the world.&lt;/dd&gt;
&lt;dt&gt;The Japanese World of Subjective Perspective&lt;/dt&gt;
&lt;dd&gt;A society where the self serves as the origin, allowing for calculations based solely on the Pythagorean method.&lt;/dd&gt;
&lt;dd&gt;In this view, the self is already established at the origin, eliminating the need for aggressive self-assertion. This creates the mental space to be considerate of others (the spirit of *omotenashi*, or hospitality).&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;This distinction holds the key to unraveling the following questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Japanese Ability to "Read the Air"
&lt;/h3&gt;

&lt;p&gt;Since Japanese people need only calculate distances within a very narrow range centered on themselves, they can compute psychological distances quickly and with minimal mental effort. This results in a high aptitude for "reading the air" (sensing the unspoken atmosphere).&lt;/p&gt;

&lt;p&gt;In contrast, Americans—existing in a world of countless Euclidean calculations—experience a kind of cognitive "overflow," wondering, "What &lt;em&gt;is&lt;/em&gt; 'the air'? Where is it?" They perceive the Japanese ability to read the atmosphere as something akin to a superpower, finding it difficult to fully comprehend.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Sanctuary of "Within Arm's Reach"
&lt;/h3&gt;

&lt;p&gt;Americans possess a mental model that regards the space "within arm's reach"—the immediate vicinity—as their own personal sanctuary (or "personal bubble"). In this sanctuary, Americans are liberated from the world of countless Euclidean calculations. It is a precious interval allowing the brain—their CPU—to idle.&lt;/p&gt;

&lt;p&gt;One could say that the American preference for oversized food is a defensive instinct of the brain, designed to keep them from venturing out of their sanctuary into the outside world as much as possible. It is not merely a matter of gluttony; it is about stockpiling supplies for an emotional shelter.&lt;/p&gt;

&lt;h3&gt;
  
  
  The True Nature of "Japan Loss"
&lt;/h3&gt;

&lt;p&gt;When Americans visit Japan, they gradually break free from the realm of infinite Euclidean calculations and settle into a low-stress world governed entirely by simple Pythagorean arithmetic. Then, just before they leave, the realization hits them: they must return to that world of endless Euclidean calculations—and face the massive cognitive load that entails for their brain's "CPU." That is the source of "Japan Loss."&lt;/p&gt;

&lt;p&gt;Consider the videos posted by overseas streamers visiting Japan: the high-energy opening reminiscent of a late-night infomercial; the gradual process of settling in; and that final, whispered "I don't wanna leave" from their hotel room or airplane seat. It isn't just because they had a good time. That sentiment is a truly poignant, heartfelt cry of distress.&lt;/p&gt;

&lt;h3&gt;
  
  
  Structural Differences Between American and Japanese Horror Movies
&lt;/h3&gt;

&lt;p&gt;American horror films almost invariably begin within the realm of the familiar—"within arm's reach"—only to have that world suddenly shattered. Even those exaggerated screams, which might strike Japanese viewers as comical, are truly cries of the soul born of the terror that comes when one's emotional sanctuary is destroyed and one is forcibly thrust back into the high-load realm of infinite Euclidean calculations. That sheer volume of voice may well be essential for asserting one's self within that world; without it, one risks simply vanishing into that terrifying void.&lt;/p&gt;

&lt;p&gt;In contrast, Japanese horror films often feature a gradual erosion of everyday life. Set in a "low-load" world governed by simple, predictable logic, the horror strikes from unseen blind spots—or manifests as a terror that eludes visual perception entirely. This creates a "high-load" cognitive loop: the unsettling paradox of something being present when it shouldn't be, or absent when it ought to be. Consequently, it is not only the Japanese who experience this dread—a form of intense psychological strain—but audiences of all backgrounds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Americans Find Japanese Horror Scarier
&lt;/h3&gt;

&lt;p&gt;American horror movies almost invariably conclude by restoring a sense of safety—bringing the viewer back to a world within arm's reach. One can return from the realm of terror to everyday life. Japanese horror, however, is different. It never returns to that space within arm's reach; indeed, there is no going back. When the film ends and you glance at your bed, you are seized by the illusion that the horror is still lurking in that very space—that zone which should have been safely within arm's reach. Japanese horror films strip them of that sense of safety within arm's reach. That is precisely why they find it so terrifying.&lt;/p&gt;




&lt;p&gt;Original Japanese text&lt;/p&gt;

&lt;h2&gt;
  
  
  人間は心理的距離をピタゴラスの定理で計算しており、心理的負荷はその計算量に比例する。
&lt;/h2&gt;

&lt;p&gt;　この前提を用いることで、様々な分野で語られる疑問を解消する、という推論が成り立つ。&lt;br&gt;
　この推論を進めるにあたり、心理的距離を測る計算モデルを下記の様に定義する。&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ピタゴラス計算 ＝ ピタゴラスの定理で求められる「原点からの距離」を測るシンプルな計算&lt;/li&gt;
&lt;li&gt;ユークリッド計算 ＝ ピタゴラス計算を複数回実行して「複数座標間の距離」を測る負荷の高い計算&lt;/li&gt;
&lt;/ul&gt;

&lt;dl&gt;
&lt;dt&gt;アメリカ的な客観視の世界&lt;/dt&gt;
&lt;dd&gt;無数の他者とのユークリッド距離を計算する社会。&lt;/dd&gt;
&lt;dd&gt;この視点では広い空間から自己を見つけ出す必要があるため、リソースを消費してでも強く自己を主張する必要がある。そうしなければ文字通り世界から自分を見失ってしまう。&lt;/dd&gt;
&lt;dt&gt;日本的な主観視の世界&lt;/dt&gt;
&lt;dd&gt;自己を原点とするためピタゴラス計算のみで計算できる社会。&lt;/dd&gt;
&lt;dd&gt;この視点では自己は常に原点として確立されているため、ことさら自己を主張する必要がない。結果として周囲を気遣う余裕（おもてなしの心）が生まれる。&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;この違いが以下の疑問を解き明かす鍵となる。&lt;/p&gt;

&lt;h3&gt;
  
  
  日本人の空気を読む能力
&lt;/h3&gt;

&lt;p&gt;　日本人は自身を中心とした極狭い範囲だけを計算すればよいので高速低負荷に心理的距離を計算できる。ゆえに空気を読む能力が高い。&lt;br&gt;
　対してアメリカ人は無数のユークリッド計算の世界で「空気って何！？どこにあるの！？」とオーバーフローを起こす。日本人の空気を読む力がまるで超能力のように感じられ、理解が追いつかない。&lt;/p&gt;

&lt;h3&gt;
  
  
  Within arm's reachという聖域
&lt;/h3&gt;

&lt;p&gt;　アメリカ人は Within arm's reach、手の届く範囲を自身の聖域（Personal Bubble）として捉える精神モデルがある。この聖域においてアメリカ人は無数のユークリッド計算世界から解放される。脳というCPUがアイドリングできる貴重な時間である。&lt;br&gt;
　アメリカ人がデカい食べ物を好むのは、この聖域からできるだけ外の世界に出ないための脳の防衛本能だと言える。ただ食いしん坊なのではない。心のシェルターの備蓄なのである。&lt;/p&gt;

&lt;h3&gt;
  
  
  日本ロスの正体
&lt;/h3&gt;

&lt;p&gt;　アメリカ人は日本に来ると無限のユークリッド計算の世界から徐々に解放され、ピタゴラス計算だけで完結する低負荷な世界へとなじんでいく。そして帰る直前になって気付いてしまう。自分がまた無数のユークリッド計算の世界へ戻らなくてはならない事に。その結果訪れる脳というCPUの負荷の大きさに。ゆえに日本ロスになる。&lt;br&gt;
　海外ストリーマーによる日本来訪動画。冒頭のまるで深夜通販番組のようなテンション、徐々に日本に馴染んでいく様子、最後の日にホテルや飛行機で洩らす「帰りたくない」という一言。楽しかったからだけではない。あれは切実に悲痛な叫びなのだ。&lt;/p&gt;

&lt;h3&gt;
  
  
  日米のホラー映画の構造の違い
&lt;/h3&gt;

&lt;p&gt;　アメリカのホラー映画は必ずと言ってよいほどWithin arm's reachから始まる。そして突然その世界を壊される。日本人にとっては滑稽にすら感じるあの大げさな叫びも、心のシェルターを破壊され、無数のユークリッド計算世界へ強制的に戻された恐怖からくるまさしく魂の叫びなのだ。そして声の大きさもまたその世界で自己を確立するために必要なのではないだろうか。そうしなければこの恐怖世界で消えてしまうから。&lt;br&gt;
　日本のホラー映画は日常がじわじわ侵食される系が多い。ピタゴラス計算だけで計算可能な低負荷な世界で、見えない死角から襲ってくる恐怖、見ても視覚に映らない恐怖。そこには居るはずなのに居ない、居ないはずなのに居るという高負荷の計算ループが発生する。ゆえに日本人に限らず様々な人種が恐怖（心理的負荷）を感じる。&lt;/p&gt;

&lt;h3&gt;
  
  
  アメリカ人が日本のホラーをより怖がる理由
&lt;/h3&gt;

&lt;p&gt;　アメリカのホラー映画は必ずと言っていいほど最後にWithin arm's reachを取り戻して終わる。恐怖の世界から日常に戻ってこれる。しかし日本のホラーは違う。決してWithin arm's reachには戻らない。戻れない。映画が終わり、ふとベッドを見るとWithin arm's reachだったはずのその空間に、まだ恐怖が潜んでいるような錯覚に襲われる。彼らは日本のホラー映画によってWithin arm's reachを失ってしまう。ゆえに、恐怖するのである。&lt;/p&gt;

</description>
      <category>japanese</category>
      <category>discuss</category>
      <category>thoughts</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
