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 6983357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:24:31+00:00 2026-05-27T18:24:31+00:00

In this question , it was suggested to use Console.in.read.toChar . It works fine

  • 0

In this question, it was suggested to use Console.in.read.toChar. It works fine in REPL, but fails to work when I put it into a script (requires user to press Enter):

#!/usr/bin/scala
!#

while (true) {
  val c = Console.in.read.toChar
  println("Got " + c)
}

So when I type a char and press Enter, I get

Got a
Got

I’m using Scala 2.9.0.1, on Ubuntu 11.04, in gnome-terminal.

What am I doing wrong?

  • 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-27T18:24:32+00:00Added an answer on May 27, 2026 at 6:24 pm

    Take a look at the answers given to a similar question here.

    The issue is that the console in Java and therefore Scala is in buffered mode and needs to be in raw mode to return individual characters instead of lines.

    Switching to raw mode is platform specific issue which is, I guess, why it’s not directly supported by Java. I assume that the REPL has set raw mode somehow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few days ago I posted this question and everyone suggested me to use
The solution to this question suggested the use of John Resig's class implementation. This
Originally posted on Server Fault , where it was suggested this question might better
In this question , it was suggested that calling repr on a dictionary would
In his answer to this question , BlackBear suggested replacing string y = Session[key]
I asked this question over Security site, and people there suggested I should have
This is a suggested re-up on a question I had before. Its really and
This continues from a previous question . I tried the suggested fix to check
My question may be very silly but here it is. I went through this
This question is related with Microcontroller programming but anyone may suggest a good algorithm

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.