Skip to content

Instantly share code, notes, and snippets.

View etcetc's full-sized avatar

Farhad etcetc

View GitHub Profile
@etcetc
etcetc / gist:e23123a0a0254a175a77
Last active October 20, 2015 01:31
Merge two dictionaries in swift using reduce
let d1 = ["a":"foo","b":"bar"]
let d2 = ["c":"car","d":"door"]
let d3 = d1.reduce(d2) { (var d, p) in
d[p.0] = p.1
return d
}
/* Result is ["b": "bar", "a": "foo", "d": "door", "c": "car"] */
@etcetc
etcetc / directiveSCopeWatch.html
Created July 27, 2015 02:03
This gist is just an exploration of different scope models for a directive
<!--
This gist is just an exploration of various types of scopes on a directive. I had mistakenly thought that
an isolate scope is a mechanism for selectively passing elements in the directive scope to the scope. So for example
if a parameter "p1" was defined in the outer scope of a directive, you could name it in the isolated scope and it
would be incorporated into the directive scope. However, this only applies to attributes that are on the directive itself
and not parameters that are in the scope at large.
If we use the "@", we are just bringing in the string assocaited with the attribute
If we use the "=", we are using the attribute value as a reference, and essentially evaluating it. This enables us
to watch that parameter for changes. It doesn't make any sense to "watch" a parameter that was brought in using "2" because it's value will never change - it's just a string