Posts

Array - Collections - Swift Programming

Array Ordered collections of values In Swift Array, Set, Dictionary types are implemented as generic collections For arrays of most  Element  types, this storage is a  contiguous block of memory . If you create an array, a set, or a dictionary, and assign it to a variable, the collection that is created will be  mutable . This means that you can change (or  mutate ) the collection after it’s created by adding, removing, or changing items in the collection.  If you assign an array, a set, or a dictionary to a constant, that collection is  immutable , and its size and contents cannot be changed. Arrays, like all variable-size collections in the standard library, use copy-on-write optimisation. Multiple copies of an array share the same storage until you modify one of the copies. When that happens, the array being modified replaces its storage with a uniquely owned copy of itself, which is then modified in place.  Optimisations are sometimes app...

Git Commands

Git Commands Start a working area clone: Clone a repository into a new directory init: Create an empty Git repository or reinitialise an existing one Work on the current change add: Add file contents to the index rm: Remove files from the working tree and from index restore: Restore working tree files mv: Move or rename a file, a directory or a symlink Collaborate fetch: Download objects and refs from another repository pull: Fetch from and integrate with another repository or a local branch push: Update remote refs along with associated objects Grow, mark and tweak your common history branch: List, create or delete branches commit: Record changes to the repository merge: Join two or more development histories together rebase: Reapply commits on top of another base tip reset: Reset current HEAD to the specified state switch: Switch branches tag: Create, list, delete or verify a tag object signed with GPG Examine the history and state bisect: Use binary search to fi...

Higher Order Functions - Swift Programming

HigherOrder Functions Introduction Sort Map Reduce Filter Introduction: What is Function? Functions  are self-contained chunks of code that perform a specific task.  Function  name should give clarity that what it does, and that name is used to “call” the function to perform its task when needed. Every function in Swift has a type, consisting of the function’s parameter types and return type. You can use this type like any other type in Swift, which makes it easy to pass functions as parameters to other functions, and to return functions from functions.  Functions can also be written within other functions to encapsulate useful functionality within a nested function scope. If the entire body of the function is a single expression, the function implicitly returns that expression. What is HigherOrder Function? A higher order function is a function that accepts one or more functions as an input (or) returns a value of function type as output (or) doing both Passing Func...