Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6795677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:22:32+00:00 2026-05-26T18:22:32+00:00

I was learning ruby through ruby koans when I faced these two functions: def

  • 0

I was learning ruby through ruby koans when I faced these two functions:

def test_flexible_quotes_can_handle_multiple_lines
   *long_string = %{
   It was the best of times,
   It was the worst of times.
   }*
   assert_equal *54*, long_string.size
end

def test_here_documents_can_also_handle_multiple_lines
   *long_string = <<EOS
   It was the best of times,
   It was the worst of times.
   EOS*
   assert_equal *53*, long_string.size
end

The problem is I cannot understand where this extra character is coming from when using flexible quotes. Ruby koans says that both answers are correct.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:22:32+00:00Added an answer on May 26, 2026 at 6:22 pm

    I’d say it’s a newline character after %{.

    >> test = %{
    ">> foo
    ">> }
    => "\nfoo\n"
    >> test.size
    => 5
    >> test = %{foo
    ">> }
    => "foo\n"
    >> test.size
    => 4
    >> test = <<EOS
    ">> foo
    ">> EOS
    => "foo\n"
    >> test.size
    => 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning Ruby on Rails. I'm using some associations (has_many :through, ...) But i'm
I'm learning MongoDB through the Mongoid Ruby gem with Rails (Rails 3 beta 3),
I learning ruby singletons and have misunderstanding with such code: class MyClass def self.class_singleton_mymethod
So right now I'm learning Ruby on Rails, and I'm working through the book
I'm just learning Ruby on Rails. I've read a few books, I've watched lots
I'm just learning ruby and trying to understand the scope of code executed in
I am learning Ruby on Rails so I'm sure I'll find this out sooner
I'm just learning ruby on rails and I have a table of user roles
I'm currently learning Ruby and RoR and I stumbled across this declaration: link_to_remote(name, options
I'm learning Ruby on Rails and doing the contactlist thing, 20 minute blog and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.