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

  • SEARCH
  • Home
  • 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 7549413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:56:34+00:00 2026-05-30T09:56:34+00:00

I tried this in scala 2.9.1 and scala 2.10 M2. Here’s my scala transcript

  • 0

I tried this in scala 2.9.1 and scala 2.10 M2.

Here’s my scala transcript after running the scala command from the terminal:

scala> case class Person(val name: String)
defined class Person

scala> val friends = List(Person("Fred"))
friends: List[Person] = List(Person(Fred))

scala> friends.head.TAB
asInstanceOf   isInstanceOf   toString       

scala> friends.head.name
res0: String = Fred

scala> :t friends
List[Person]

scala> :t friends.head
Person

Scala knows that friends is of type List[Person] and that friends.head is of type Person. Shouldn’t it be able to suggest name as a potential completion?

If that’s not supported, I’d be happy to look into fixing it. I peeked around in the source code (scala-2.9.1.final-sources/src/jline/src/main/java/scala/tools/jline/console/completer) but I’d appreciate any pointers to how to fix it.

Thanks.

Tim

  • 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-30T09:56:35+00:00Added an answer on May 30, 2026 at 9:56 am

    You’re right, it’s not supported. The prefix (friends.head) isn’t actually run through the type-checker to determine the accurate type.

    If you want to play around with this, you should use the latest version of Scala, and run with -Dscala.repl.debug to see what’s happening.

    scala> ps.head.
    complete(ps.head., 8) last = (, -1), verbosity: 0
    List[$read$$iw$$iw$Person] completions ==>  List(removeDuplicates, toStream, stringPrefix, reverse, span, dropWhile, takeWhile, splitAt, takeRight, slice, drop, take, toList, +:, ++, mapConserve, reverse_:::, :::, ::, companion, lastIndexWhere, indexWhere, segmentLength, isDefinedAt, lengthCompare, sameElements, dropRight, last, reduceRight, reduceLeft, foldRight, foldLeft, find, count, exists, forall, foreach, apply, length, productPrefix, productIterator, seq, corresponds, iterator, toSeq, toString, view, indices, sorted, sortBy, sortWith, padTo, :+, updated, patch, distinct, intersect, diff, union, contains, containsSlice, lastIndexOfSlice, indexOfSlice, endsWith, startsWith, reverseIterator, reverseMap, combinations, permutations, size, lastIndexOf, indexOf, prefixLength, lift, andThen, orElseFast, orElse, compose, canEqual, zipWithIndex, zipAll, zip, copyToArray, sliding, grouped, head, toIterator, toIterable, isEmpty, transpose, flatten, unzip3, unzip, genericBuilder, withFilter, toTraversable, inits, tails, init, lastOption, tail, headOption, scanRight, scanLeft, scan, groupBy, partition, collect, filterNot, filter, flatMap, map, ++:, hasDefiniteSize, repr, isTraversableAgain, par, addString, mkString, toMap, toSet, toBuffer, toIndexedSeq, toArray, copyToBuffer, minBy, maxBy, max, min, product, sum, aggregate, fold, reduceOption, reduce, reduceRightOption, reduceLeftOption, :\, /:, collectFirst, nonEmpty, /:\, asInstanceOf, isInstanceOf, productArity, productElement)
    List[$read$$iw$$iw$Person] -> 'head' ==>  Some(()Object (31 members))
    ()Object completions ==>  List(toString, asInstanceOf, isInstanceOf)
    package <root> completions ==>  List(target, project, lib_managed, quicktime, ch, scala, apple, java, com, sunw, javax, sun, org, asInstanceOf, isInstanceOf, toString)
    package <root> -> 'ps' ==>  None
    object Predef -> 'ps' ==>  None
    package scala -> 'ps' ==>  None
    package java.lang -> 'ps' ==>  None
    tryCompletion(Parsed(ps.head. / 8), _) lastBuf = ps.head., lastCursor = 8, p.position = 8
    
    asInstanceOf   isInstanceOf   toString   
    

    You probably should seek the advice of Paul Phillips, the REPL author. I’m sure he’s considered (if not half implemented) this already, and would know the difficulty better than anyone else.

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

Sidebar

Related Questions

I tried this here: http://jsfiddle.net/92HXT/1/ but it does not work. It only works if
I tried this: #!/usr/bin/python from wsgiref.simple_server import make_server from cgi import parse_qs, escape import
I have defined a class in Scala (2.9.1) as follows: class A(val neighbors: Array[Option[A]])
I'm totally new to Scala. Here I have tried to assign a empty array
I've grabbed some Scala CSV parsing code from here: Use Scala parser combinator to
I have this class in scala trait PageComponent { protected var page:Page = _
I've tried this different ways, but nothing seems to be working. Here is what
I am trying to implement C#'s ExpandoObject -like class in Scala. This is how
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
Having tried this query a million different ways, I can't seem to SELECT 'count_lonely_vehicles'

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.