Effectively Reduce your Code using the Reduce Function

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

КОМЕНТАРІ • 54

  • @w0mblemania
    @w0mblemania 7 років тому +10

    Thanks Brian. I know you were showing how to use reduce(), but for those following along at home, strings can be easily joined using, well, the _joined(:)_ method. Using Apple's example:
    let cast = ["Vivien", "Marlon", "Kim", "Karl"]
    let list = cast.joined(separator: ", ")
    print(list)
    // "Vivien, Marlon, Kim, Karl"
    Also, the _reduce()_ method can be boiled down even further. e.g.
    let sum = [1, 2, 3, 4].reduce(0, +)
    or, subtraction:
    let result = [1, 2, 3, 4].reduce(1000, -)
    Cheers.

  •  5 років тому

    I had written swift over 1 year and and know reduce function util I watched this video :))))). Thanks a lot.

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

    3 things I'd like to say:
    1. Thanks for your videos, I really like them.
    2. I'd love to see more intermediate/advanced stuff. I've been reading tons of Swift blogs and love seeing things a junior dev might not think about. For example, swiftbysundell.com is a great blog with very cool tips on Swift code. Viewing videos with more advanced content would be amazing.
    3. I used to make UA-cam videos and found out that if you record things in segments and not a single continuous take, you can then edit the clips and reduce the length of the video making it more concise, plus you can avoid your filler words and you have the chance to think before speaking in the camera not having the pressure of finding something to say.
    Anyways, great content as always. I'm really looking forward to viewing more Android content. Cheers!

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

    Very helpful Brian! Greatest of all time indeed!

  • @jonathannairn3341
    @jonathannairn3341 7 років тому +4

    Hey Brian been here since you started and are just about to buy your instagram course!
    Just wondering if you have any plans on making a video about git and github that would be greatly appreciated,
    anyways have a great day man!

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

      You can find git courses all over the Net.

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

      It's integrated in XCode 9, check out his video from Brian Advent
      -> ua-cam.com/video/RWlG08FM5FA/v-deo.html

  • @szymonrybczak
    @szymonrybczak 4 роки тому

    Thanks for video! It was very useful.

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

    kudos on the channel growth :D

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

    This comes really close to recursion. I didn't even know this was an option!

  • @kosteaproduction
    @kosteaproduction 7 років тому +20

    how to seduce your code

  • @abdouett3676
    @abdouett3676 7 років тому +6

    Thanks Brian for the video. We can make also: let mySum = [1, 2, 3, 4].reduce(0, +) without { $0 + $1 }

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

      abdou ett exactly what I was about to comment

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 років тому +3

      Indeed, I totally forgot about this even simpler method.

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

      yes, why not just make it completely unreadable? or maintainable? if you have any clue about perl, bash, csh $0, $1 is much easier. the better solution is to create a custom infix operator and tune the code for the underlying type. the fastest method is just to use the Accelerate framework.

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

    Nice stuff brian, the reduce function might look a bit confusing due to its signature. Thank you !

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

    How do I make my workstation like yours, aka, terminal below, right pane1-var values, right pane2-help

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

    I have xcode 8 and swift 3...how can i update to the latest version? I don't see any updates available in the app store ! :(

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

    Are functions like map, reduce and filter chainable in Swift?

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

    I think from a functional style res is also known as a accumulator

  • @cinquain0
    @cinquain0 5 років тому

    This video is a classic

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

    As always, awesome!! Thanks for updating the instagram course to XCode 9 @ firebase 4👍🏻😃

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

    Nice video and thanks.

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

    Yo, where can I get these beats?

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

      I have a friend that sent me a bunch of music files. I think premiumbeats.com has some good music.

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

    Do other languages have a similar function? Such as java

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 років тому +3

      I don't believe Java has built-in functions like this.

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

      Lets Build That App ok thanks I'm more into Android developer currently so I will have to see if Kotlin had something similar.

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

    I've been trying to get into the functional thing, but it's just not readable enough. It's hard to intuitively explain to people who are unfamiliar with functional programming. On the other hand, everyone is familiar with for loops.

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

      Yep initially its not for everyone, but once you get into the real world you'll see it everywhere so make sure to understand it now.

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

    That last one could be simplified to let string = someArray.joined(" ") couldn't it?

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

    which programming language is this?

  • @haroonurrasheed4340
    @haroonurrasheed4340 5 років тому

    Brain you could have used array built in function to Join Words :)

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

    Waiting for the next video in android series 😅😅😅

  • @JamesBond-mq7pd
    @JamesBond-mq7pd 7 років тому +4

    Mvp
    mvc
    mvvm
    mv*
    ***
    can we talk about this?

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

    I just had a look at my local job market the other day and 95% of job offeres had objective-c and swift in them while only one had objective-c/swift in the description. That really makes me question sense of lewrning iOS development. Going freelance while being limited to one mobile OS is not the best idea either. Outdated objective-c just can't die fast enough.

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

      Huh? Are you saying 95% of jobs are iOS related but learning iOS doesn't make sense?

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

      95% of only iOS job offers. iOS job market is a drop in the ocean in comparison to web development for instance. So yes, it's a very bad deal, especially that you work for small companies that lack benefits or even a parking space. The job market is very limited and restrictive in my area.

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

    Hello Sir I am Shailesh Sir Can we get the IMEI number of iPhone device in swift code?
    How we get update if any contact is added in iPhone than update that contact number to the server how develop that code in swift?

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

    Nice shirt

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

    perhaps you say perhaps a bit much :)

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

      Haha, I have a bunch of filler words I use while trying to move onto the next topic and wondering if what I just said made sense. Recordings are tough -_-

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

      hehe yeah, I know what you are saying I have similar issues on my vids. Great content as always though!

    • @LetsBuildThatApp
      @LetsBuildThatApp  7 років тому +2

      Great videos on your channel, must be very fun explaining the concepts of 3D rendering through the Maya interface. I remember rendering a few scenes in 3D studio max way back in the day and it was difficult but great fun.

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

    First!

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

      Hi brian, great video! never knew i have been using it without knowing it's name. :D
      Can we use reduce for other than simple task like add, multiple and combine? if so, what are other example?