Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #swift channel.

  • 09/29 12:00:04 Blythe: Xcode 9
  • 09/29 12:00:11 Naomi: I think my Xcode is bonk
  • 09/29 12:00:17 Naomi: I need to reinstall
  • 09/29 12:00:24 Blythe: oh my
  • 09/29 12:01:04 Blythe: before going that far, could you try quitting, deleting the `~/Library/Developer/Xcode/DerivedData` folder, and relaunching?
  • 09/29 12:02:22 Naomi: ok thanks
  • 09/29 12:29:51 Naomi: I had the Beta I see Xcode 9 is officially out now, so I deleted Xcode from the applications folder and emptied trash should I also delete ~/Library/Developer/Xcode/ before installing the new Xcode 9?
  • 09/29 12:50:22 Blythe: Nope, keep that folder please. The derived data folder _under_ that folder sometimes gets into a bad state but I’ve never deleted library/developer/Xcode in its entirety
  • 09/29 13:54:51 Naomi: I ended up deleting the Developer Folder, any cache and all beta stuff installed Xcode 9 and everything works now only complaint is the Simulator in Playgrounds is Soooooooo SLOW
  • 09/30 02:04:26 Naomi:
    var mySonsAge = 1.0
    let experience = "times the experience as your kid"
    
    
    print("\(round(myAge + 21) / round(mySonsAge + 21)) \(experience)")
    How do I round up to 2 instead of showing 1.95454545
  • 09/30 12:07:34 Charles: I think you may want to round after doing division, instead of before
  • 10/02 11:38:50 Lionel: Definitely what Matt said... generally you want to keep your numbers as precise as possible until you need to round them, otherwise you can accumulate little rounding errors along the way and get a wrong answer entirely
  • 10/10 15:30:14 Blythe: Here's a fun party trick:
    $R0: Int = 6
      2> [true, true, true].reduce(true, &&)
    error: repl.swift220: error: cannot invoke 'reduce' with an argument list of type '(Bool, (Bool, @autoclosure () throws -> Bool) throws -> Bool)'
    [true, true, true].reduce(true, &&)
                       ^
    
    Why? Let's take a look at the declarations of `+` and `&&` I guess: `public static func +(lhs: Int, rhs: Int) -> Int` `public static func &&(lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows -> Bool` Right then. `+` and `&&` are plain old functions whose arguments are always evaluated. With `+` that's fine. With `&&`, that would break the short-circuit semantics we're used to in other languages. So the `rhs` is automatically wrapped in a `() -> Bool` which is only called when `lhs` is true.
  • 10/11 10:50:00 Blythe: on further reflection, there's no reason that ever should have worked.
    6
    cljs.user=> (reduce and [true true true])
                        ^
    WARNING: Can't take value of macro cljs.core/and at line 1 
    undefined is not an object (evaluating 'f.cljs$core$IFn$_invoke$arity$2')
    	cljs.core/-reduce [cljs.core/IReduce] (cljs/core.cljs53216)
    	cljs.core/reduce (cljs/core.cljs24701)
  • 10/16 15:56:05 Melany: @Blythe of course, you can always just wrap it in a function: `(reduce #(and % %2) [true true true])`
  • *Usernames have been changed to protect the innocent.
We're currently 983 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!