Skip to content

Improve implicit convertion #195

@letientai299

Description

@letientai299

The following Scala code won't compile

import rx.lang.scala.Observable
object Solution {
  def main(args: Array[String]): Unit = {
    Observable.create[Int](s => s.onNext(1))
      .subscribe(println(_))
  }
}

While the same thing in Java works fine.

import rx.Observable;
public class Main {
  public static void main(String[] args) {
    Observable.create(s -> s.onNext(0))
        .subscribe(System.out::println);
  }
}

Also, in the following compilable version, we shouldn't have to explicit add Int as the type param;

import rx.lang.scala.{Observable, Subscriber}
object Solution {
  def main(args: Array[String]): Unit = {
    Observable.create[Int](
      s => {
        s.onNext(1)
        Subscriber()
      }
    )
      .subscribe(println(_))
  }
}

Edit
Remove the redundant call to Scheduers.newThread() in the last snippet. That's related to another issues I reported to Jetbrains (you can find it here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions