Skip to content

Instantly share code, notes, and snippets.

@mackuba
Last active June 11, 2016 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mackuba/10386fc83a336dc8e338 to your computer and use it in GitHub Desktop.
Save mackuba/10386fc83a336dc8e338 to your computer and use it in GitHub Desktop.
I made a diff of the versions of Swift ebooks between the early June and early July versions. I'm not sure if I can post it publicly, but here's a summary of what's updated:
  • across all sections:

    • changed all occurrences of the a..b operator to a..<b
    • changed all occurrences of a Something[] array type to [Something]
    • changed some occurrences of an Array(values) array initialization to [Something](values)
    • changed some occurrences of a Dictionary<Key, Value> dictionary type to [Key: Value]
  • Swift Tour:

  • Collection Types:

    • removed info about the different behavior of Array from "Mutability of Collections" and moved the section to the beginning
    • "Dictionaries": added sections "Dictionary Type Shorthand Syntax" and "Hash Values for Dictionary Key Types"
  • Closures: renamed sort function to sorted

  • Enumerations: in the barcode example, "identifier" part was split into "manufacturer code" and "product code" parts

  • Classes and Structures, "Assignment and Copy Behavior for Collection Types":

    • renamed to "Assignment and Copy Behavior for Strings, Arrays, and Dictionaries"

    • removed the paragraph:

      However, arrays have slightly different copying behavior from dictionaries and other structures when they are assigned to a constant or variable, and when they are passed to a function or method.

    • removed the sections:

      • "Assignment and Copy Behavior for Dictionaries"
      • "Assignment and Copy Behavior for Arrays"
      • "Ensuring That an Array Is Unique"
      • "Checking Whether Two Arrays Share the Same Elements"
      • "Forcing a Copy of an Array"
  • Initialization, "Memberwise Initializers for Structure Types":

    • changed default structure initializer behavior from:

      In addition to the default initializers mentioned above, structure types automatically receive a memberwise initializer if they provide default values for all of their stored properties and do not define any of their own custom initializers.

    • to:

      Structure types automatically receive a memberwise initializer if they do not define any of their own custom initializers. This is true even if the structure’s stored properties do not have default values.

  • Automatic Reference Counting: changed CreditCard number field type to UInt64 and added an explanation below

  • Generics: added a section "Extending a Generic Type"

  • Types

    • "Array Type": the three-dimensional array is now declared as [[[Int]]] instead of Int[][][]

    • added section "Dictionary Type"

    • "Optional Type": removed the part:

      When declaring an optional type, be sure to use parentheses to properly scope the ? operator. As an example, to declare an optional array of integers, write the type annotation as (Int[])?; writing Int[]? produces an error.

  • Attributes: removed exported entry

  • across all sections: updated occurrences of Array to the new syntax

  • Adopting Cocoa Design Patterns: added "Lazy Initialization" and "Key-Value Observing" section placeholders

  • Working with Cocoa Data Types:

    • "Arrays": added the line below and a matching code sample:

      Alternatively, you can place a downcast after the array you are iterating over—both of these styles are equivalent.

    • added a section "Dictionaries"

  • Writing Swift Classes with Objective-C Behavior:

    • "Implementing Core Data Managed Object Subclasses": added a second paragraph about namespacing and a screenshot

Script for "normalizing" the ebooks to remove the noise from the diff:

#!/usr/bin/env ruby

dir = ARGV.first or raise "Pass a directory path as argument"

Dir.glob("#{dir}/**/*.*html").each do |file|
  contents = File.read(file)
  contents.gsub!(%r("//apple_ref[^"]+"), '""')
  contents.gsub!(%r("TP\d+[^"]+"), '""')
  contents.gsub!(%r(#TP[^"]+"), '#"')
  contents.gsub!(%r(<dt class="term">), %(\n<dt class="term">))
  contents.gsub!(%r(<p class="para">), %(\n<p class="para">))
  File.write(file, contents)
end

How to use:

./normalize_ebook.rb v1.epub
./normalize_ebook.rb v2.epub
diff -ur v1.epub v2.epub > swift-beta3.diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment