{"id":41195,"date":"2026-03-05T07:09:25","date_gmt":"2026-03-05T07:09:25","guid":{"rendered":"https:\/\/www.railscarma.com\/?p=41195"},"modified":"2026-03-05T07:09:29","modified_gmt":"2026-03-05T07:09:29","slug":"ruby-multiline-comments-explained-with-examples","status":"publish","type":"post","link":"https:\/\/www.railscarma.com\/fr\/blog\/ruby-multiline-comments-explained-with-examples\/","title":{"rendered":"Commentaires multilignes en Ruby expliqu\u00e9s avec des exemples"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"41195\" class=\"elementor elementor-41195\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1d3daf62 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1d3daf62\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3cc8ca0e\" data-id=\"3cc8ca0e\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-633c514d elementor-widget elementor-widget-text-editor\" data-id=\"633c514d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><\/p>\n<p>Ruby, known for its elegant and developer-friendly syntax, handles comments in a somewhat unique way compared to many other programming languages. While single-line comments (starting with #) are ubiquitous and widely used, multiline (or block) comments have a dedicated syntax that many <a href=\"https:\/\/www.railscarma.com\/fr\/embaucher-un-developpeur-ruby-on-rails\/\">Ruby developers<\/a> rarely touch in day-to-day work. This article dives deep into Ruby&#8217;s multiline comment system \u2014 how it works, why it&#8217;s designed this way, its quirks, best practices, common pitfalls, real-world use cases, and plenty of practical examples. We&#8217;ll cover both the <a href=\"https:\/\/docs.ruby-lang.org\/en\/master\/syntax\/comments_rdoc.html\">official block comment<\/a> syntax (=begin \/ =end) and the far more common idiom of using multiple single-line comments to achieve the same effect. By the end, you&#8217;ll understand exactly when (and when not) to use each approach.<\/p>\n<h2><b>1. Ruby&#8217;s Two Comment Types: Inline vs Block<\/b><\/h2>\n<p>According to the official Ruby documentation (ruby-lang.org syntax reference), Ruby supports exactly two kinds of code comments:<\/p>\n<p><\/p>\n<ul class=\"wp-block-list\"><p><\/p>\n<li>Inline comments \u2014 start with # and continue until the end of the line<\/li>\n<p><\/p>\n<li>Block comments \u2014 start with =begin (on its own line) and end with =end (also on its own line)<\/li>\n<p><\/p>\n<\/ul>\n<p><\/p>\n<p>Inline comments are by far the most common. They can appear:<\/p>\n<p><\/p>\n<ul class=\"wp-block-list\"><p><\/p>\n<li>On a line by themselves<\/li>\n<p><\/p>\n<li>After code on the same line<\/li>\n<p><\/p>\n<li>Indented inside blocks<\/li>\n<p><\/p>\n<\/ul>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em># This is a standalone comment<\/em>\n\nname = \"Alice\"          <em># inline comment after code<\/em>\n\nclass User\n  <em># Documentation comment inside a class<\/em>\n  def initialize(name)\n    @name = name\n  end\nend<\/code><\/pre>\n<p><\/p>\n<p>Block comments, on the other hand, are Ruby&#8217;s true multiline comment mechanism \u2014 but they come with strict rules and limited practical use.<\/p>\n<h2><b>2. The =begin \/ =end Block Comment Syntax<\/b><\/h2>\n<p><span style=\"font-size: 16px;\">The official multiline comment syntax looks like this:<\/span><\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em>=begin\n<\/em><em>This is a multiline comment block.\n<\/em><em>Everything between =begin and =end is ignored by the Ruby parser.\n<\/em>\n<em>You can write as many lines as you want here.\n<\/em><em>No need to prefix each line with #.\n<\/em>\n<em>This is useful for long explanations, copyright notices,\n<\/em><em>or temporarily disabling large sections of code.\n<\/em><em>=end<\/em>\n\nputs \"This line runs normally\"<\/code><\/pre>\n<p><\/p>\n<p>Key rules (these are enforced by the parser):<\/p>\n<p><\/p>\n<ol class=\"wp-block-list\" start=\"1\"><p><\/p>\n<li>=begin must appear alone at the beginning of a line (no leading whitespace allowed).<\/li>\n<p><\/p>\n<li>=end must also appear alone at the beginning of a line (no leading whitespace).<\/li>\n<p><\/p>\n<li>Both markers must start in column 1 (leftmost position).<\/li>\n<p><\/p>\n<li>The content between them can be indented freely \u2014 only the markers themselves cannot be indented.<\/li>\n<p><\/p>\n<li>The block comment ends at the first =end that appears at the start of a line.<\/li>\n<p><\/p>\n<\/ol>\n<p><\/p>\n<p>Because of rule #1 and #2, this syntax cannot be used inside indented blocks such as methods, classes, modules, or conditionals.<\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code>def calculate_total(items)\n  =begin               <em># \u2190 Syntax error!<\/em>\n  This won't work because =begin is indented\n  =end\n  items.sum\nend<\/code><\/pre>\n<p><\/p>\n<p>Trying to run the above code produces a syntax error:<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code>syntax error, unexpected '=', expecting `end'\n  =begin\n   ^<\/code><\/pre>\n<p><\/p>\n<p>This indentation restriction is the single biggest reason most experienced Ruby developers avoid =begin \/ =end in everyday code.<\/p>\n<h2><b>3. The Practical Multiline Comment: Multiple # Lines<\/b><\/h2>\n<p>Because true block comments are so restrictive, the community-standard way to comment out or document multiple lines is simply to prefix each line with #:<\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em># This is the most common way to write multiline comments in Ruby<\/em>\n<em># You can comment out an entire method like this:<\/em>\n<em># def old_broken_method<\/em>\n<em>#   puts \"This was causing errors\"<\/em>\n<em>#   do_dangerous_stuff!<\/em>\n<em>#   crash_the_program<\/em>\n<em># end<\/em>\n\n<em># Or write longer documentation:<\/em>\n<em># Calculates the factorial of n using recursion.<\/em>\n<em># Warning: very slow for large n (&gt; ~1000)<\/em>\n<em># For production code prefer the iterative version.<\/em>\n<em># Examples:<\/em>\n<em>#   factorial(5)  # =&gt; 120<\/em>\n<em>#   factorial(0)  # =&gt; 1<\/em>\ndef factorial(n)\n  return 1 if n &lt;= 1\n  n * factorial(n - 1)\nend<\/code><\/pre>\n<p><\/p>\n<p>Modern editors and IDEs (VS Code, RubyMine, Sublime, Vim with plugins, etc.) make this trivial:<\/p>\n<p><\/p>\n<ul class=\"wp-block-list\"><p><\/p>\n<li>Highlight multiple lines \u2192 press Ctrl+\/ (or Cmd+\/ on macOS) \u2192 every line gets a # prefix<\/li>\n<p><\/p>\n<li>Press the same shortcut again \u2192 removes the prefixes<\/li>\n<p><\/p>\n<\/ul>\n<p><\/p>\n<p>This workflow is so fast and reliable that most Rubyists never feel the need for =begin \/ =end.<\/p>\n<h2><b>4. Comparing the Two Approaches Side-by-Side<\/b><\/h2>\n<p><\/p>\n<figure class=\"wp-block-table\">\n<table class=\"has-fixed-layout\">\n<tbody>\n<tr>\n<th>Fonctionnalit\u00e9<\/th>\n<th>Multiple # lines<\/th>\n<th>=begin \/ =end block<\/th>\n<\/tr>\n<tr>\n<td>Can be indented<\/td>\n<td>Yes<\/td>\n<td>No \u2014 markers must be at column 1<\/td>\n<\/tr>\n<tr>\n<td>Works inside methods\/classes<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Easy to toggle with editor shortcuts<\/td>\n<td>Yes (built-in in almost every editor)<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Looks clean in documentation<\/td>\n<td>Good (especially with yard\/rdoc markup)<\/td>\n<td>Acceptable, but less common<\/td>\n<\/tr>\n<tr>\n<td>Can nest<\/td>\n<td>Yes (just more #)<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Used in real-world Ruby projects<\/td>\n<td>Very common<\/td>\n<td>Rare (mostly in generated or very old code)<\/td>\n<\/tr>\n<tr>\n<td>Parsing performance impact<\/td>\n<td>Negligible<\/td>\n<td>Negligible<\/td>\n<\/tr>\n<tr>\n<td>Official feature<\/td>\n<td>Yes (inline comment)<\/td>\n<td>Yes (block comment)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p><\/p>\n<h2><b>5. Special Use Cases Where =begin \/ =end Still Appears<\/b><\/h2>\n<p>Even though it&#8217;s uncommon, the block comment syntax is occasionally useful or encountered in the wild.<\/p>\n<p><b>A. Embedded \/ RDoc \/ YARD documentation at the top of a file<\/b><\/p>\n<p>Many Ruby core files and older gems use block comments for long file-level documentation:<\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em>=begin rdoc\n<\/em>\n<em>= Overview\n<\/em>\n<em>This module provides utilities for date\/time calculations\n<\/em><em>that are timezone-aware and support business days.\n<\/em>\n<em>=end<\/em>\n\nmodule BusinessTime\n  <em># ... rest of the code<\/em>\nend<\/code><\/pre>\n<p><\/p>\n<p>The =begin rdoc marker tells RDoc\/YARD parsers that this is documentation (not regular code comment). Some tools also support =begin pod, =begin markdown, etc.<\/p>\n<p><b>B. Conditional file sections during development<\/b><\/p>\n<p>Sometimes you&#8217;ll see developers use block comments to quickly disable entire sections at the top level:<\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em>=begin\n<\/em><em>require 'expensive_debug_gem'\n<\/em><em>require 'memory_profiler'\n<\/em>\n<em>MemoryProfiler.report do\n<\/em><em>  # very slow code here\n<\/em><em>end\n<\/em><em>=end<\/em>\n\n<em># Normal app code continues...<\/em><\/code><\/pre>\n<p><\/p>\n<p>Because it&#8217;s at the top level (not indented), =begin \/ =end works perfectly here.C. Legacy code or code generationYou may encounter =begin \/ =end in very old Ruby 1.8\/1.9 codebases, Rails plugin skeletons, or code generated by tools.<\/p>\n<h2><b>6. Common Pitfalls and Mistakes<\/b><\/h2>\n<p><b>Mistake 1: Indenting the markers<\/b><\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code>  =begin          <em># \u2190 Syntax error<\/em>\n    important note\n  =end<\/code><\/pre>\n<p><\/p>\n<p><b>Mistake 2: Forgetting that =end must be alone<\/b><\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em>=begin\n<\/em><em>stuff\n<\/em><em>=end<\/em> some note     <em># \u2190 Syntax error, parser keeps looking for =end<\/em><\/code><\/pre>\n<p><\/p>\n<p><b>Mistake 3: Expecting nested block comments<\/b><\/p>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em>=begin\n<\/em><em>outer comment\n<\/em><em>  =begin\n<\/em><em>  inner comment   # \u2190 ignored, treated as normal text\n<\/em><em>  =end\n<\/em><em>more outer\n<\/em><em>=end<\/em><\/code><\/pre>\n<p><\/p>\n<p>Block comments do not nest.<\/p>\n<p><b>Mistake 4: Using block comments for TODOs inside methods<\/b><\/p>\n<p>Developers sometimes try this \u2014 and immediately regret it when they see the syntax error.<\/p>\n<h2><b>7. Best Practices for Commenting in Ruby (2025\u20132026 Style)<\/b><\/h2>\n<p><\/p>\n<ol class=\"wp-block-list\" start=\"1\"><p><\/p>\n<li>Prefer multiple # lines for almost everything.<\/li>\n<p><\/p>\n<li>Use # for inline explanations, edge-case notes, and algorithm steps.<\/li>\n<p><\/p>\n<li>Write RDoc\/YARD documentation above methods\/classes\/modules using # lines (not =begin).<\/li>\n<p><\/p>\n<li>Reserve =begin \/ =end for:<br><ul class=\"wp-block-list\"><p><\/p>\n<li>File-level copyright\/legal notices<\/li>\n<p><\/p>\n<li>Long RDoc markup at file start<\/li>\n<p><\/p>\n<li>Temporary top-level debugging blocks<\/li>\n<p><\/p>\n<\/ul>\n<p><\/p>\n<\/li>\n<p><\/p>\n<li>Keep comments up-to-date \u2014 outdated comments are worse than no comments.<\/li>\n<p><\/p>\n<li>Use tools like rubocop \u2014 it has rules like Style\/CommentAnnotation to standardize TODO\/FIXME\/NOTE keywords.<\/li>\n<p><\/p>\n<\/ol>\n<p><\/p>\n<h2><b>8. Quick Reference: All Ruby Comment Styles in One Place<\/b><\/h2>\n<p><\/p>\n<p>rubis<\/p>\n<p><\/p>\n<pre class=\"wp-block-code\"><code><em># Single-line comment<\/em>\n\n<em># Multiline via multiple single-line comments<\/em>\n<em># Line 2<\/em>\n<em># Line 3<\/em>\n\n<em>=begin\n<\/em><em>True block comment.\n<\/em><em>Can span many lines.\n<\/em><em>No # needed on each line.\n<\/em><em>=end<\/em>\n\n<em>=begin rdoc          # Special for documentation tools\n<\/em><em>= Heading\n<\/em>\n<em>Explanation paragraph.\n<\/em>\n<em>* list item\n<\/em><em>* another\n<\/em><em>=end<\/em>\n\nclass Example\n  <em># This is allowed (indented inline comment)<\/em>\n  def demo\n    <em># Everything here uses #<\/em>\n    <em># No =begin possible here<\/em>\n  end\nend<\/code><\/pre>\n<p><\/p>\n<h2><b>Conclusion<\/b><\/h2>\n<p>Ruby&#8217;s multiline comment story is simple once you accept one fact: the idiomatic way to comment multiple lines is just to use many # symbols. The =begin \/ =end syntax exists, is well-defined in the official language specification, and has niche uses \u2014 but in modern Ruby code (2025+), you&#8217;ll rarely see it inside methods or classes because of its indentation limitation. Mastering both approaches helps when reading legacy code, contributing to Ruby core, or working with documentation-generation tools. But for your day-to-day work? Stick with # \u2014 your future self (and your teammates) will thank you.<\/p>\n<p><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t  <div class=\"related-post slider\">\r\n        <div class=\"headline\">Articles Similaires<\/div>\r\n    <div class=\"post-list owl-carousel\">\r\n\r\n            <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Qu&#039;est-ce que Offliberty Ruby Gem et comment fonctionne-t-il ?\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/quest-ce-que-offliberty-ruby-gem-et-comment-fonctionne-t-il\/?related_post_from=41304\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/What-is-Offliberty-Ruby-Gem-and-How-It-Works.png\" class=\"attachment-full size-full wp-post-image\" alt=\"Offliberty Ruby Gem\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/What-is-Offliberty-Ruby-Gem-and-How-It-Works.png 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/What-is-Offliberty-Ruby-Gem-and-How-It-Works-300x113.png 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/What-is-Offliberty-Ruby-Gem-and-How-It-Works-768x288.png 768w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/What-is-Offliberty-Ruby-Gem-and-How-It-Works-18x7.png 18w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Qu&#039;est-ce que Offliberty Ruby Gem et comment fonctionne-t-il ?\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/quest-ce-que-offliberty-ruby-gem-et-comment-fonctionne-t-il\/?related_post_from=41304\">\r\n        Qu'est-ce que Offliberty Ruby Gem et comment fonctionne-t-il ?  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"M\u00e9thode Rails link_to : Le guide complet avec des exemples\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/rails-link_to-method-the-complete-guide-with-examples\/?related_post_from=41296\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Rails-link_to-Method-The-Complete-Guide-with-Examples.png\" class=\"attachment-full size-full wp-post-image\" alt=\"M\u00e9thode Rails link_to\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Rails-link_to-Method-The-Complete-Guide-with-Examples.png 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Rails-link_to-Method-The-Complete-Guide-with-Examples-300x113.png 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Rails-link_to-Method-The-Complete-Guide-with-Examples-768x288.png 768w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Rails-link_to-Method-The-Complete-Guide-with-Examples-18x7.png 18w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"M\u00e9thode Rails link_to : Le guide complet avec des exemples\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/rails-link_to-method-the-complete-guide-with-examples\/?related_post_from=41296\">\r\n        M\u00e9thode Rails link_to : Le guide complet avec des exemples  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Comment construire une plateforme SaaS \u00e9volutive en utilisant Ruby on Rails\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/how-to-build-a-scalable-saas-platform-using-ruby-on-rails\/?related_post_from=41273\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Build-a-SaaS-Platform-Using-Ruby-on-Rails.png\" class=\"attachment-full size-full wp-post-image\" alt=\"Construire une plateforme SaaS avec Ruby on Rails\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Build-a-SaaS-Platform-Using-Ruby-on-Rails.png 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Build-a-SaaS-Platform-Using-Ruby-on-Rails-300x113.png 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Build-a-SaaS-Platform-Using-Ruby-on-Rails-768x288.png 768w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Build-a-SaaS-Platform-Using-Ruby-on-Rails-18x7.png 18w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Comment construire une plateforme SaaS \u00e9volutive en utilisant Ruby on Rails\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/how-to-build-a-scalable-saas-platform-using-ruby-on-rails\/?related_post_from=41273\">\r\n        Comment construire une plateforme SaaS \u00e9volutive en utilisant Ruby on Rails  <\/a>\r\n\r\n        <\/div>\r\n              <div class=\"item\">\r\n            <div class=\"thumb post_thumb\">\r\n    <a  title=\"Guide de correspondance des expressions rationnelles en Ruby (2026) avec exemples\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/ruby-regex-match-guide-with-examples\/?related_post_from=41249\">\r\n\r\n      <img decoding=\"async\" width=\"800\" height=\"300\" src=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Ruby-Regex-Match-Guide-with-Examples.png\" class=\"attachment-full size-full wp-post-image\" alt=\"Ruby Regex Match\" srcset=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Ruby-Regex-Match-Guide-with-Examples.png 800w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Ruby-Regex-Match-Guide-with-Examples-300x113.png 300w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Ruby-Regex-Match-Guide-with-Examples-768x288.png 768w, https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/04\/Ruby-Regex-Match-Guide-with-Examples-18x7.png 18w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\r\n\r\n    <\/a>\r\n  <\/div>\r\n\r\n  <a class=\"title post_title\"  title=\"Guide de correspondance des expressions rationnelles en Ruby (2026) avec exemples\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/ruby-regex-match-guide-with-examples\/?related_post_from=41249\">\r\n        Guide de correspondance des expressions rationnelles en Ruby (2026) avec exemples  <\/a>\r\n\r\n        <\/div>\r\n      \r\n  <\/div>\r\n\r\n  <script>\r\n      <\/script>\r\n  <style>\r\n    .related-post {}\r\n\r\n    .related-post .post-list {\r\n      text-align: left;\r\n          }\r\n\r\n    .related-post .post-list .item {\r\n      margin: 10px;\r\n      padding: 10px;\r\n          }\r\n\r\n    .related-post .headline {\r\n      font-size: 14px !important;\r\n      color: #999999 !important;\r\n          }\r\n\r\n    .related-post .post-list .item .post_thumb {\r\n      max-height: 220px;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n          }\r\n\r\n    .related-post .post-list .item .post_title {\r\n      font-size: 14px;\r\n      color: #000000;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .post-list .item .post_excerpt {\r\n      font-size: 12px;\r\n      color: #3f3f3f;\r\n      margin: 10px 0px;\r\n      padding: 0px;\r\n      display: block;\r\n      text-decoration: none;\r\n          }\r\n\r\n    .related-post .owl-dots .owl-dot {\r\n          }\r\n\r\n      <\/style>\r\n      <script>\r\n      jQuery(document).ready(function($) {\r\n        $(\".related-post .post-list\").owlCarousel({\r\n          items: 2,\r\n          responsiveClass: true,\r\n          responsive: {\r\n            0: {\r\n              items: 1,\r\n            },\r\n            768: {\r\n              items: 2,\r\n            },\r\n            1200: {\r\n              items: 2,\r\n            }\r\n          },\r\n                      rewind: true,\r\n                                loop: true,\r\n                                center: false,\r\n                                autoplay: true,\r\n            autoplayHoverPause: true,\r\n                                nav: true,\r\n            navSpeed: 1000,\r\n            navText: ['<i class=\"fas fa-chevron-left\"><\/i>', '<i class=\"fas fa-chevron-right\"><\/i>'],\r\n                                dots: false,\r\n            dotsSpeed: 1200,\r\n                                                    rtl: false,\r\n          \r\n        });\r\n      });\r\n    <\/script>\r\n  <\/div>","protected":false},"excerpt":{"rendered":"<p>Ruby, known for its elegant and developer-friendly syntax, handles comments in a somewhat unique way compared to many other programming languages. While single-line comments (starting with #) are ubiquitous and widely used, multiline (or block) comments have a dedicated syntax that many Ruby developers rarely touch in day-to-day work. This article dives deep into Ruby&#8217;s &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/ruby-regex-match-guide-with-examples\/\"> <span class=\"screen-reader-text\">Guide de correspondance des expressions rationnelles en Ruby (2026) avec exemples<\/span> Lire la suite \u00bb<\/a><\/p>","protected":false},"author":5,"featured_media":41200,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1224],"tags":[],"class_list":["post-41195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ruby Multiline Comments Explained with Examples - RailsCarma<\/title>\n<meta name=\"description\" content=\"Ruby multiline comments explained with examples, syntax, best practices, and when to use =begin and =end for cleaner, readable code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.railscarma.com\/fr\/blog\/ruby-multiline-comments-explained-with-examples\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ruby Multiline Comments Explained with Examples - RailsCarma\" \/>\n<meta property=\"og:description\" content=\"Ruby multiline comments explained with examples, syntax, best practices, and when to use =begin and =end for cleaner, readable code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.railscarma.com\/fr\/blog\/ruby-multiline-comments-explained-with-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"RailsCarma - Ruby on Rails Development Company specializing in Offshore Development\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RailsCarma\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-05T07:09:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-05T07:09:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nikhil\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@railscarma\" \/>\n<meta name=\"twitter:site\" content=\"@railscarma\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikhil\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/\"},\"author\":{\"name\":\"Nikhil\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/person\/1aa0357392b349082303e8222c35c30c\"},\"headline\":\"Ruby Multiline Comments Explained with Examples\",\"datePublished\":\"2026-03-05T07:09:25+00:00\",\"dateModified\":\"2026-03-05T07:09:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/\"},\"wordCount\":914,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.railscarma.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png\",\"articleSection\":[\"Blogs\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/\",\"url\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/\",\"name\":\"Ruby Multiline Comments Explained with Examples - RailsCarma\",\"isPartOf\":{\"@id\":\"https:\/\/www.railscarma.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png\",\"datePublished\":\"2026-03-05T07:09:25+00:00\",\"dateModified\":\"2026-03-05T07:09:29+00:00\",\"description\":\"Ruby multiline comments explained with examples, syntax, best practices, and when to use =begin and =end for cleaner, readable code.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage\",\"url\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png\",\"contentUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png\",\"width\":800,\"height\":300,\"caption\":\"Ruby Multiline Comments\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.railscarma.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ruby Multiline Comments Explained with Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.railscarma.com\/#website\",\"url\":\"https:\/\/www.railscarma.com\/\",\"name\":\"RailsCarma - Ruby on Rails Development Company specializing in Offshore Development\",\"description\":\"RailsCarma is a Ruby on Rails Development Company in Bangalore. We specialize in Offshore Ruby on Rails Development based out in USA and India. Hire experienced Ruby on Rails developers for the ultimate Web Experience.\",\"publisher\":{\"@id\":\"https:\/\/www.railscarma.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.railscarma.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.railscarma.com\/#organization\",\"name\":\"RailsCarma\",\"url\":\"https:\/\/www.railscarma.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png\",\"contentUrl\":\"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png\",\"width\":200,\"height\":46,\"caption\":\"RailsCarma\"},\"image\":{\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/RailsCarma\/\",\"https:\/\/x.com\/railscarma\",\"https:\/\/www.linkedin.com\/company\/railscarma\/\",\"https:\/\/myspace.com\/railscarma\",\"https:\/\/in.pinterest.com\/railscarma\/\",\"https:\/\/www.youtube.com\/channel\/UCx3Wil-aAnDARuatTEyMdpg\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/person\/1aa0357392b349082303e8222c35c30c\",\"name\":\"Nikhil\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.railscarma.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054f31ff35e9917aaf631b8025ef679d42dd21792012d451763138d66d02a4c0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054f31ff35e9917aaf631b8025ef679d42dd21792012d451763138d66d02a4c0?s=96&d=mm&r=g\",\"caption\":\"Nikhil\"},\"sameAs\":[\"https:\/\/www.railscarma.com\/hire-ruby-on-rails-developer\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ruby Multiline Comments Explained with Examples - RailsCarma","description":"Ruby multiline comments explained with examples, syntax, best practices, and when to use =begin and =end for cleaner, readable code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.railscarma.com\/fr\/blog\/ruby-multiline-comments-explained-with-examples\/","og_locale":"fr_FR","og_type":"article","og_title":"Ruby Multiline Comments Explained with Examples - RailsCarma","og_description":"Ruby multiline comments explained with examples, syntax, best practices, and when to use =begin and =end for cleaner, readable code.","og_url":"https:\/\/www.railscarma.com\/fr\/blog\/ruby-multiline-comments-explained-with-examples\/","og_site_name":"RailsCarma - Ruby on Rails Development Company specializing in Offshore Development","article_publisher":"https:\/\/www.facebook.com\/RailsCarma\/","article_published_time":"2026-03-05T07:09:25+00:00","article_modified_time":"2026-03-05T07:09:29+00:00","og_image":[{"width":800,"height":300,"url":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png","type":"image\/png"}],"author":"Nikhil","twitter_card":"summary_large_image","twitter_creator":"@railscarma","twitter_site":"@railscarma","twitter_misc":{"\u00c9crit par":"Nikhil","Dur\u00e9e de lecture estim\u00e9e":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#article","isPartOf":{"@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/"},"author":{"name":"Nikhil","@id":"https:\/\/www.railscarma.com\/#\/schema\/person\/1aa0357392b349082303e8222c35c30c"},"headline":"Ruby Multiline Comments Explained with Examples","datePublished":"2026-03-05T07:09:25+00:00","dateModified":"2026-03-05T07:09:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/"},"wordCount":914,"commentCount":0,"publisher":{"@id":"https:\/\/www.railscarma.com\/#organization"},"image":{"@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png","articleSection":["Blogs"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/","url":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/","name":"Ruby Multiline Comments Explained with Examples - RailsCarma","isPartOf":{"@id":"https:\/\/www.railscarma.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage"},"image":{"@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png","datePublished":"2026-03-05T07:09:25+00:00","dateModified":"2026-03-05T07:09:29+00:00","description":"Ruby multiline comments explained with examples, syntax, best practices, and when to use =begin and =end for cleaner, readable code.","breadcrumb":{"@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#primaryimage","url":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png","contentUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2026\/03\/Ruby-Multiline-Comments-Explained-with-Examples.png","width":800,"height":300,"caption":"Ruby Multiline Comments"},{"@type":"BreadcrumbList","@id":"https:\/\/www.railscarma.com\/blog\/ruby-multiline-comments-explained-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.railscarma.com\/"},{"@type":"ListItem","position":2,"name":"Ruby Multiline Comments Explained with Examples"}]},{"@type":"WebSite","@id":"https:\/\/www.railscarma.com\/#website","url":"https:\/\/www.railscarma.com\/","name":"RailsCarma - Soci\u00e9t\u00e9 de d\u00e9veloppement Ruby on Rails sp\u00e9cialis\u00e9e dans le d\u00e9veloppement offshore","description":"RailsCarma est une soci\u00e9t\u00e9 de d\u00e9veloppement Ruby on Rails \u00e0 Bangalore. Nous sommes sp\u00e9cialis\u00e9s dans le d\u00e9veloppement offshore Ruby on Rails, bas\u00e9s aux \u00c9tats-Unis et en Inde. Embauchez des d\u00e9veloppeurs Ruby on Rails exp\u00e9riment\u00e9s pour une exp\u00e9rience Web ultime.","publisher":{"@id":"https:\/\/www.railscarma.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.railscarma.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/www.railscarma.com\/#organization","name":"RailsCarma","url":"https:\/\/www.railscarma.com\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png","contentUrl":"https:\/\/www.railscarma.com\/wp-content\/uploads\/2020\/08\/railscarma_logo.png","width":200,"height":46,"caption":"RailsCarma"},"image":{"@id":"https:\/\/www.railscarma.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RailsCarma\/","https:\/\/x.com\/railscarma","https:\/\/www.linkedin.com\/company\/railscarma\/","https:\/\/myspace.com\/railscarma","https:\/\/in.pinterest.com\/railscarma\/","https:\/\/www.youtube.com\/channel\/UCx3Wil-aAnDARuatTEyMdpg"]},{"@type":"Person","@id":"https:\/\/www.railscarma.com\/#\/schema\/person\/1aa0357392b349082303e8222c35c30c","name":"Nikhil","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.railscarma.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054f31ff35e9917aaf631b8025ef679d42dd21792012d451763138d66d02a4c0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054f31ff35e9917aaf631b8025ef679d42dd21792012d451763138d66d02a4c0?s=96&d=mm&r=g","caption":"Nikhil"},"sameAs":["https:\/\/www.railscarma.com\/hire-ruby-on-rails-developer\/"]}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/posts\/41195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/comments?post=41195"}],"version-history":[{"count":4,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/posts\/41195\/revisions"}],"predecessor-version":[{"id":41199,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/posts\/41195\/revisions\/41199"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/media\/41200"}],"wp:attachment":[{"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/media?parent=41195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/categories?post=41195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.railscarma.com\/fr\/wp-json\/wp\/v2\/tags?post=41195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}