Future Calculations (in Scala)

Поділитися
Вставка
  • Опубліковано 29 лис 2024

КОМЕНТАРІ • 10

  • @zakariyaetouzi7967
    @zakariyaetouzi7967 6 років тому

    Good explanation just as I thought
    What is the next video? Could you PLZ make a playlist of the related videos

    • @MarkLewis
      @MarkLewis  6 років тому +2

      Thank you. All of my videos are in playlists, and I wish that UA-cam had a feature where they automatically linked to playlists that the creators of videos place the videos in. I've requested it, but it hasn't happened. The main playlist for this video is ua-cam.com/play/PLLMXbkbDbVt98z_6KWt3fU3W5jTOja9zY.html. It is also part of a much longer playlist that covers a semester of material.

    • @zakariyaetouzi7967
      @zakariyaetouzi7967 6 років тому

      Playlist saved (y)
      Thank you so much

    • @MarkLewis
      @MarkLewis  6 років тому +1

      You are very welcome. I hope that it proves useful to you. If you go to my channel, you should be able to see all of the playlists that I have on various topics.

  • @hatsuharu333
    @hatsuharu333 7 років тому

    I’ve seen some scala code that does things like:
    val someA = something.createSomeA(....)
    Future {
    someA.doSomething1(....)
    someA.doSomething2(.....)
    }
    // some other expressions
    I don’t really understand what the future is doing in this case as it’s not assigned to anything. Could someone explain what the Future is doing here?

    • @MarkLewis
      @MarkLewis  7 років тому +1

      Code that looks like this is simply interested in the side effects of the methods doSomething1 and doSomething2, and wants them to happen in a separate thread. Spawning a Future is probably the easiest way to make something happen in a separate thread in Scala, so this isn't uncommon, even if you have no interest in the result of the Future.

  • @arunbm123
    @arunbm123 8 років тому

    Line : f2.onComplete {
    onComplete method is abstract in trait Future.......how is it possible to call like you are doing in this code ? Please give some tips

    • @MarkLewis
      @MarkLewis  8 років тому

      When we create the Future, we actually get some subtype of Future. That subtype has the method implemented.
      I need to go back through these videos. It is advised to use foreach instead of onSuccess. I need to make certain I did that.

    • @arunbm123
      @arunbm123 8 років тому

      ok Thanks.....Where is source code for that Concrete class Future, I mean which File .

    • @MarkLewis
      @MarkLewis  8 років тому

      I don't know. I have never gone to look. You could go into the source for the scala.concurrent.Future companion object and see what the apply method returns. It actually comes from the implicit execution context that you are using, so that probably won't give you the answer you are looking for. I would argue that you really shouldn't know that in general, and that if you ever write code that depends on a particular implementation, you are doing something bad that will make your code brittle.