Search Results

Search found 972 results on 39 pages for 'scala'.

Page 19/39 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • What's the best way of accessing a DRb object (e.g. Ruby Queue) from Scala (and Java)?

    - by Tom Morris
    I have built a variety of little scripts using Ruby's very simple Queue class, and share the Queue between Ruby and JRuby processes using DRb. It would be nice to be able to access these from Scala (and maybe Java) using JRuby. I've put together something Scala and the JSR-223 interface to access jruby-complete.jar. import javax.script._ class DRbQueue(host: String, port: Int) { private var engine = DRbQueue.factory.getEngineByName("jruby") private var invoker = engine.asInstanceOf[Invocable] engine.eval("require \"drb\" ") private var queue = engine.eval("DRbObject.new(nil, \"druby://" + host + ":" + port.toString + "\")") def isEmpty(): Boolean = invoker.invokeMethod(this.queue, "empty?").asInstanceOf[Boolean] def size(): Long = invoker.invokeMethod(this.queue, "length").asInstanceOf[Long] def threadsWaiting: Long = invoker.invokeMethod(this.queue, "num_waiting").asInstanceOf[Long] def offer(obj: Any) = invoker.invokeMethod(this.queue, "push", obj.asInstanceOf[java.lang.Object]) def poll(): Any = invoker.invokeMethod(this.queue, "pop") def clear(): Unit = { invoker.invokeMethod(this.queue, "clear") } } object DRbQueue { var factory = new ScriptEngineManager() } (It conforms roughly to java.util.Queue interface, but I haven't declared the interface because it doesn't implement the element and peek methods because the Ruby class doesn't offer them.) The problem with this is the type conversion. JRuby is fine with Scala's Strings - because they are Java strings. But if I give it a Scala Int or Long, or one of the other Scala types (List, Set, RichString, Array, Symbol) or some other custom type. This seems unnecessarily hacky: surely there has got to be a better way of doing RMI/DRb interop without having to use JSR-223 API. I could either make it so that the offer method serializes the object to, say, a JSON string and takes a structural type of only objects that have a toJson method. I could then write a Ruby wrapper class (or just monkeypatch Queue) to would parse the JSON. Is there any point in carrying on with trying to access DRb from Java/Scala? Might it just be easier to install a real message queue? (If so, any suggestions for a lightweight JVM-based MQ?)

    Read the article

  • rewrite not a member of LiftRules

    - by José Leal
    Hi guys, I was following http://www.assembla.com/wiki/show/liftweb/URL_Rewriting tutorial for url rewritting in liftweb.. but I get this error: error: value rewrite is not a member of object net.liftweb.http.LiftRules .. it is really odd.. and the documentation says that it exists. I'm using idea IDE, and I've done everything from scratch, using the lift maven blank archifact. Some more info: [INFO] ------------------------------------------------------------------------ [INFO] Building Joseph3 [INFO] task-segment: [tomcat:run] [INFO] ------------------------------------------------------------------------ [INFO] Preparing tomcat:run [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [yuicompressor:compress {execution: default}] [INFO] nb warnings: 0, nb errors: 0 [INFO] artifact org.mortbay.jetty:jetty: checking for updates from scala-tools.org [INFO] artifact org.mortbay.jetty:jetty: checking for updates from central [INFO] [compiler:compile {execution: default-compile}] [INFO] Nothing to compile - all classes are up to date [INFO] [scala:compile {execution: default}] [INFO] Checking for multiple versions of scala [INFO] /home/dpz/Scala/Doit/Joseph3/src/main/scala:-1: info: compiling [INFO] Compiling 2 source files to /home/dpz/Scala/Doit/Joseph3/target/classes at 1274922123910 [ERROR] /home/dpz/Scala/Doit/Joseph3/src/main/scala/bootstrap/liftweb/Boot.scala:16: error: value rewrite is not a member of object net.liftweb.http.LiftRules [INFO] LiftRules.rewrite.prepend(NamedPF("ProductExampleRewrite") { [INFO] ^ [ERROR] one error found [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1(Exit value: 1) [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 19 seconds [INFO] Finished at: Thu May 27 03:02:07 CEST 2010 [INFO] Final Memory: 20M/175M [INFO] ------------------------------------------------------------------------ Process finished with exit code 1 enter code here

    Read the article

  • How to specialize a type parameterized argument to multiple different types for in Scala?

    - by jmount
    I need a back-check (please). In an article ( http://www.win-vector.com/blog/2010/06/automatic-differentiation-with-scala/ ) I just wrote I stated that it is my belief in Scala that you can not specify a function that takes an argument that is itself a function with an unbound type parameter. What I mean is you can write: def g(f:Array[Double]=>Double,Array[Double]):Double but you can not write something like: def g(f[Y]:Array[Y]=>Double,Array[Double]):Double because Y is not known. The intended use is that inside g() I will specialize fY to multiple different types at different times. You can write: def g[Y](f:Array[Y]=>Double,Array[Double]):Double but then f() is of a single type per call to g() (which is exactly what we do not want). However, you can get all of the equivalent functionality by using a trait extension instead insisting on passing around a function. What I advocated in my article was: 1) Creating a trait that imitates the structure of Scala's Function1 trait. Something like: abstract trait VectorFN { def apply[Y](x:Array[Y]):Y } 2) declaring def g(f:VectorFN,Double):Double (using the trait is the type). This works (people here on StackOverflow helped me find it, and I am happy with it)- but am I mis-representing Scala by missing an even better solution?

    Read the article

  • Fastest Functional Language

    - by Farouk
    I've recently been delving into functional programming especially Haskell and F#, the prior more so. After some googling around I could not find a benchmark comparison of the more prominent functional languages (Scala,F# etc). I know it's not necessarily fair to some of the languages (Scala comes to mind) given that they are hybrids, but I just wanna know which outperforms which on what operations and overall.

    Read the article

  • Grafting Scala 2.8 into a Netbeans NBAndroid Project...What steps am I missing?

    - by Michael Kohout
    Hi All; Due to Apple's recent T+C hijinks, I've become interested in developing for Android. Anyways, I'm trying to get a mixed-language Android 2.1 project going in Netbeans 6.8 (with the NBAndroid 0.10 plugin). The two languages being Java and Scala(2.8 head build). To give you a basic idea of what the app does right now, it's just a simple "Hello World" app. To get this to build, I've modified the projects's build.xml file: -- -injars ${scala-library}(!META-INF/MANIFEST.MF,!library.properties) -outjars "${build.classes.dir}/classes.min.jar" -libraryjars "${file.reference.android.jar}" -dontwarn -dontoptimize -dontobfuscate -keep public class * extends android.app.Activity -keep public class scala.xml.include.sax.Main** I've gotten the project so that it'll build, but it errors on startup in my Android Emulator(inside the emulator Android tells me my application has stopped unexpectedly). So my questions are: Does anyone see what I may be doing wrong? And is there any way to get access to the logs that the emulator must create? thanks Mike Kohout

    Read the article

  • How do Scala parser combinators compare to Haskell's Parsec?

    - by artif
    I have read that Haskell parser combinators (in Parsec) can parse context sensitive grammars. Is this also true for Scala parser combinators? If so, is this what the "into" (aka "") function is for? What are some strengths/weaknesses of Scala's implementation of parser combinators, vs Haskell's? Do they accept the same class of grammars? Is it easier to generate error messages or do other miscellaneous useful things with one or the other? How does packrat parsing (introduced in Scala 2.8) fit into this picture? Is there a webpage or some other resource that shows how different operators/functions/DSL-sugar from one language's implementation maps onto the other's?

    Read the article

  • How to customize Json serialization using Scala and Play Framework?

    - by Jonas
    I would like to serialize some Scala case classes to Json. E.g my case class looks like: case class Item ( id: Int, name: String, price: BigDecimal, created: java.util.Date) and I would like to serialize it to Json like this: {"id":3, "name": "apple", "price": 8.00, "created": 123424434} so I need a custom serilization for BigDecimal and for Date. Where I want the data in milliseconds since 1 jan 1970. When using Scala and Play Framework, I can return Json using Json(myObject), but how do I customize the serialization? Or is there any recommended Scala library?

    Read the article

  • How to check whether a String fully matches a Regex in Scala?

    - by mkneissl
    Assume I have a Regex pattern I want to match many Strings to. val Digit = """\d""".r I just want to check whether a given String fully matches the Regex. What is a good and idiomatic way to do this in Scala? I know that I can pattern match on Regexes, but this is syntactically not very pleasing in this case, because I have no groups to extract: scala> "5" match { case Digit() => true case _ => false } res4: Boolean = true Or I could fall back to the underlying Java pattern: scala> Digit.pattern.matcher("5").matches res6: Boolean = true which is not elegant, either. Is there a better solution?

    Read the article

  • How do I return a String from a for comprehension in Scala?

    - by Vonn
    Scala Newbie alert: basically I'm trying to do something like this: where I pattern match and return a String. scala> def processList(list: List[String], m: String): String={list foreach (x=> m match{ | case "test" => "we got test" | case "test1"=> "we got test1"})} :10: error: type mismatch; found : Unit required: String def processList(list: List[String], m: String): String={list foreach (x= m match{ I know I can set a var and return it after the for comp... but that doesn't seem to be the Scala way.

    Read the article

  • Strange Play Framework 2.2 exceptions after trying to add MySQL / slick

    - by Mike Cialowicz
    I'm working on a Play 2.2 application, and things have gone a bit south on me since I've tried adding my DB layer. Below are my build.sbt dependencies. As you can see I use mysql-connector-java and play-slick: libraryDependencies ++= Seq( jdbc, anorm, cache, "joda-time" % "joda-time" % "2.3", "mysql" % "mysql-connector-java" % "5.1.26", "com.typesafe.play" %% "play-slick" % "0.5.0.8", "com.aetrion.flickr" % "flickrapi" % "1.1" ) My application.conf has some similarly simple DB stuff in it: db.default.url="jdbc:mysql://localhost/myDb" db.default.driver="com.mysql.jdbc.Driver" db.default.user="root" db.default.pass="" This is what it looks like when my Play server starts: [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 (Server started, use Ctrl+D to stop and go back to the console...) [info] Compiling 1 Scala source to C:\bbq\cats\in\space [info] play - database [default] connected at jdbc:mysql://localhost/myDb [info] play - Application started (Dev) So, it appears that Play can connect to the MySQL DB just fine (I think). However, I get this exception when I make any request to my server: [error] p.nettyException - Exception caught in Netty java.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lscala/concurren t/ExecutionContext; at play.core.Invoker$.<init>(Invoker.scala:24) ~[play_2.10.jar:2.2.0] at play.core.Invoker$.<clinit>(Invoker.scala) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$Implicits$.defaultContext$lzycompu te(Execution.scala:7) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$Implicits$.defaultContext(Executio n.scala:6) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$.<init>(Execution.scala:10) ~[play _2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$.<clinit>(Execution.scala) ~[play_ 2.10.jar:2.2.0] The odd thing is that the 2nd request (to the exact same URL, same controller, no changes) comes back with a different error: [error] p.nettyException - Exception caught in Netty java.lang.NoClassDefFoundError: Could not initialize class play.api.libs.concurr ent.Execution$ at play.core.server.netty.PlayDefaultUpstreamHandler.handleAction$1(Play DefaultUpstreamHandler.scala:194) ~[play_2.10.jar:2.2.0] at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(Pla yDefaultUpstreamHandler.scala:169) ~[play_2.10.jar:2.2.0] at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageRecei ved(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na] at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived (HttpContentDecoder.java:108) ~[netty-3.6.5.Final.jar:na] at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:29 6) ~[netty-3.6.5.Final.jar:na] at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessage Received(FrameDecoder.java:459) ~[netty-3.6.5.Final.jar:na] The URL / controller that I'm requesting just renders a static web page and doesn't do anything of any significance. It was working just fine before I started adding my DB layer. I'm rather stuck. Any help would be greatly appreciated, thanks. I'm using Scala 2.10.2, Play 2.2.0, and MySQL Server 5.6.14.0 (community edition).

    Read the article

  • scalacheck/scalatest not found: how to add it in sbt/scala?

    - by Pavel Reich
    I've installed typesafe-stack from http://typesafe.com/stack/download on my ubuntu12, than I created a play project (g8 typesafehub/play-scala) and now I want to add scalatest or scalacheck to my project. So my_app/project/plugins.sbt has the following lines: // The Typesafe repository resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // Use the Play sbt plugin for Play projects addSbtPlugin("play" % "sbt-plugin" % "2.0.1") Then I added scalatest using addSbtPlugin: addSbtPlugin("org.scalatest" %% "scalatest" % "2.0.M1" % "test") and now it fails with the following message when I run 'sbt test' [info] Resolving org.scalatest#scalatest;2.0.M1 ... [warn] module not found: org.scalatest#scalatest;2.0.M1 [warn] ==== typesafe-ivy-releases: tried [warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml [warn] ==== local: tried [warn] ~/.ivy2/local/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml [warn] ==== Typesafe repository: tried [warn] http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom [warn] ==== typesafe-ivy-releases: tried [warn] http://repo.typesafe.com/typesafe/ivy- releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom What I don't understand: why does it use this http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom URL instead of the real one http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1/2.0.M1/scalatest_2.9.1-2.0.M1.pom? Quite the same problem I have with scalacheck: it also tries to download using sbt-version specific artifactId whereas the repository has only scala-version specific. What am I doing wrong? I understand there must be a switch in sbt somewhere, not to use sbt-version as part of the artifact URL? I also tried using this in my plugins.sbt libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test" but looks like it is completely ignored by sbt and scalatest.jar hasn't appeared in the classpath: my_app/test/AppTest.scala:1: object scalatest is not a member of package org [error] import org.scalatest.FunSuite because the output of sbt clean && sbt test has lots of Resolving org.easytesting#fest-util;1.1.6 or just another library, but nothing about scalatest. I use scala 2.9.1 and sbt 0.11.3, trying to use scalatest 2.0.M1 and 1.8; scalacheck: resolvers ++= Seq( "snapshots" at "http://oss.sonatype.org/content/repositories/snapshots", "releases" at "http://oss.sonatype.org/content/repositories/releases" ) libraryDependencies ++= Seq( "org.scalacheck" %% "scalacheck" % "1.9" % "test" ) With the same outcome, i.e. it uses the sbtVersion specific POM URL, which doesn't exist. What am I doing wrong? Thanks.

    Read the article

  • Are there any tools for performing static analysis of Scala code?

    - by Roman Kagan
    Are there any tools for performing static analysis of Scala code, similar to FindBugs and PMD for Java or Splint for C/C++? I know that FindBugs works on the bytecode produced by compiling Java, so I'm curious as to how it would work on Scala. Google searches (as of 27 October 2009) reveal very little. Google searches (as of 01 February 2010) reveal this question.

    Read the article

  • Has anyone got the vim taglist plugin working with Scala?

    - by Eric Hauser
    I'm having trouble getting the taglist plugin working properly with Scala. I've installed the plugin and ctags and verified that it works properly with Java and C++. I then followed the instructions on this page (minus the Lift specific instructuions), but was nothing shows up in the taglist window when I open it while editing a Scala file. Has anyone got this working and what are the proper steps? Thanks.

    Read the article

  • How to store date into Mysql database with play framework in scala?

    - by Rahul Kulhari
    I am working with play framework with scala and what am i doing : login page to login into web app sign up page to register into web app after login i want to store all databases values to user what i want to do: when user register for web app then i want to store user values into database with current time and date but my form is giving error. error: List(FormError(dates,error.required,List())),None) controllers/Application.scala object Application extends Controller { val ta:Form[Keyword] = Form( mapping( "id" -> ignored(NotAssigned:Pk[Long]), "word" -> nonEmptyText, "blog" -> nonEmptyText, "cat" -> nonEmptyText, "score"-> of[Long], "summaryId"-> nonEmptyText, "dates" -> date("yyyy-MM-dd HH:mm:ss") )(Keyword.apply)(Keyword.unapply) ) def index = Action { Ok(html.index(ta)); } def newTask= Action { implicit request => ta.bindFromRequest.fold( errors => {println(errors) BadRequest(html.index(errors))}, keywo => { Keyword.create(keywo) Ok(views.html.data(Keyword.all())) } ) } models/keyword.scala case class Keyword(id: Pk[Long],word: String,blog: String,cat: String,score: Long, summaryId: String,dates: Date ) object Keyword { val keyw = { get[Pk[Long]]("keyword.id") ~ get[String]("keyword.word")~ get[String]("keyword.blog")~ get[String]("keyword.cat")~ get[Long]("keyword.score") ~ get[String]("keyword.summaryId")~ get[Date]("keyword.dates") map { case id~blog~cat~word~score~summaryId~dates => Keyword(id,word,blog,cat,score, summaryId,dates) } } def all(): List[Keyword] = DB.withConnection { implicit c => SQL("select * from keyword").as(Keyword.keyw *) } def create(key: Keyword){DB.withConnection{implicit c=> SQL("insert into keyword values({word},{blog}, {cat}, {score},{summaryId},{dates})").on('word-> key.word,'blog->key.blog, 'cat -> key.cat, 'score-> key.score, 'summaryId -> key.summaryId, 'dates->new Date()).executeUpdate } } views/index.scala.html @(taskForm: Form[Keyword]) @import helper._ @main("Todo list") { @form(routes.Application.newTask) { @inputText(taskForm("word")) @inputText(taskForm("blog")) @inputText(taskForm("cat")) @inputText(taskForm("score")) @inputText(taskForm("summaryId")) <input type="submit"> <a href="">Go Back</a> } } please give me some idea to store date into mysql databse and date is not a field of form

    Read the article

  • How do I provide basic configuration for a Scala application?

    - by Dave
    I am working on a small GUI application written in Scala. There are a few settings that the user will set in the GUI and I want them to persist between program executions. Basically I want a scala.collections.mutable.Map that automatically persists to a file when modified. This seems like it must be a common problem, but I have been unable to find a lightweight solution. How is this problem typically solved?

    Read the article

  • What type of webapp is the sweet spot for Scala's Lift framework?

    - by ajay
    What kind of applications are the sweet spot for Scala's lift web framework. My requirements: Ease of development and maintainability Ready for production purposes. i.e. good active online community, regular patches and updates for security and performance fixes etc. Framework should survive a few years. I don't want to write a app in a framework for which no updates/patches are available after 1 year. Has good UI templating engines Interoperation with Java (Scala satisfies this arleady. Just mentioning here for completeness sake) Good component oriented development. Time required to develop should be proportion to the complexity of web application. Should not be totally configuration based. I hate it when code gets automatically generated for me and does all sorts of magic under the hood. That is a debugging nightmare. Amount of Lift knowledge required to develop a webapp should be proportional to the complexity of the web application. i.e I should't have to spend 10+ hours learning Lift just to develop a simple TODO application. (I have knowledge of Databases, Scala) Does Lift satisfy these requirements?

    Read the article

  • Why would a variable in Scala code mysteriously become null?

    - by Alex R
    I've isolated the problem down to this: Predef.println("the value of argv1 here is " + argv(1)); var n: $ = undef; n = argv(1); Predef.println("the value of argv1 here is " + argv(1)); Predef.println("the value of n here is " + n); Predef.println("the class of n here is " + n.getClass); Here's the definition of $: class $ { println("constructed a new $ of type: " + this.getClass); def value: $ = this; def toValue: Value = { new ConstStringValue(this.toString()) }; def -(sym: Symbol): $ = { println("looked up: " + sym); this } def -(sym: $): $ = { println("looked up: " + sym); this } def update(sym: Symbol, any: Any) { println("update called: " + sym + "=" + any); } def apply(sym: Symbol) = { this } def apply(obj: $) = { this } def apply() = { this } def +(o:$) = this.toValue.div(o.toValue) def *(o:$) = this.toValue.mul(o.toValue) def >(o:$) = this.toValue.gt(o.toValue) def <(o:$) = this.toValue.lt(o.toValue) def ++() = { this } def -=(o:$) = { this } } When run, the code prints: the value of argv1 here is 10 the value of argv1 here is 10 the value of n here is null java.lang.NullPointerException at test_1_php$.include(_tmp.scala:149) at php.script.main(php.scala:57) at test_1_php.main(_tmp.scala) [...] Why would n mysteriously lose its value (or fail to take one on)?

    Read the article

  • Why does one of these statements compile in Scala but not the other?

    - by Jeff
    (Note: I'm using Scala 2.7.7 here, not 2.8). I'm doing something pretty simple -- creating a map based on the values in a simple, 2-column CSV file -- and I've completed it easily enough, but I'm perplexed at why my first attempt didn't compile. Here's the code: // Returns Iterator[String] private def getLines = Source.fromFile(csvFilePath).getLines // This doesn't compile: def mapping: Map[String,String] = { Map(getLines map { line: String => val pairArr = line.split(",") pairArr(0) -> pairArr(1).trim() }.toList:_*) } // This DOES compile def mapping: Map[String,String] = { def strPair(line: String): (String,String) = { val pairArr = line.split(",") pairArr(0) -> pairArr(1).trim() } Map(getLines.map( strPair(_) ).toList:_*) } The compiler error is CsvReader.scala:16: error: value toList is not a member of (St ring) = (java.lang.String, java.lang.String) [scalac] possible cause: maybe a semicolon is missing before `value toList'? [scalac] }.toList:_*) [scalac] ^ [scalac] one error found So what gives? They seem like they should be equivalent to me, apart from the explicit function definition (vs. anonymous in the nonworking example) and () vs. {}. If I replace the curly braces with parentheses in the nonworking example, the error is "';' expected, but 'val' found." But if I remove the local variable definition and split the string twice AND use parens instead of curly braces, it compiles. Can someone explain this difference to me, preferably with a link to Scala docs explaining the difference between parens and curly braces when used to surround method arguments?

    Read the article

  • How Does One Make Scala Control Abstraction in Repeat Until?

    - by peter_pilgrim
    Hi I am Peter Pilgrim. I watched Martin Odersky create a control abstraction in Scala. However I can not yet seem to repeat it inside IntelliJ IDEA 9. Is it the IDE? package demo class Control { def repeatLoop ( body: = Unit ) = new Until( body ) class Until( body: = Unit ) { def until( cond: = Boolean ) { body; val value: Boolean = cond; println("value="+value) if ( value ) repeatLoop(body).until(cond) // if (cond) until(cond) } } def doTest2(): Unit = { var y: Int = 1 println("testing ... repeatUntil() control structure") repeatLoop { println("found y="+y) y = y + 1 } { until ( y < 10 ) } } } The error message reads: Information:Compilation completed with 1 error and 0 warnings Information:1 error Information:0 warnings C:\Users\Peter\IdeaProjects\HelloWord\src\demo\Control.scala Error:Error:line (57)error: Control.this.repeatLoop({ scala.this.Predef.println("found y=".+(y)); y = y.+(1) }) of type Control.this.Until does not take parameters repeatLoop { In the curried function the body can be thought to return an expression (the value of y+1) however the declaration body parameter of repeatUntil clearly says this can be ignored or not? What does the error mean?

    Read the article

  • Is there a Scala version of .irbrc or another way to define some default libraries for REPL use?

    - by Tom Morris
    I've written a little library that uses implicits to add functionality that one only needs when using the REPL in Scala. Ruby has libraries like this - for things like pretty printing, firing up text editors (like the interactive_editor gem which invokes Vim from irb - see this post), debuggers and the like. The library I am trying to write adds some methods to java.lang.Class and java.lang.reflect classes using the 'pimp my library' implicit conversion process to help you go and find documentation (initially, with Google, then later possibly with a JavaDoc/ScalaDoc viewer, and maybe the StackOverflow API eventually!). It's an itch-scratching library: I spend so much time copying and pasting classnames into Google that I figured I may as well automate the process. It is the sort of functionality that developers will want to add to their system for use only in the REPL - they shouldn't really be adding it to projects (partly because it may not be something that their fellow developers want, but also because if you are doing some exploratory development, it may be with just a Scala REPL that's not being invoked by an IDE or build tool). In my case, I want to include a few classes and set up some implicits - include a .jar on the CLASSPATH and import it, basically. In Ruby, this is the sort of thing that you'd add to your .irbrc file. Other REPLs have similar ways of setting options and importing libraries. Is there a similar file or way of doing this for the Scala REPL?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >