This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # How can we harmonize the types of a Square class and a Rectangle class | |
| # so that it's possible to write a rescale function that works on both? | |
| # | |
| # As we saw in class Wed, if we’re doing this in Java, inheritance cannot | |
| # solve this problem in a simple way: both `Square extends Rectangle` | |
| # and `Rectangle extends Square` end up violating the Liskov Substitution | |
| # Principle. While there is a nice “is-a” relationship here — all squares | |
| # are rectangles! — that does not translate nicely into Java’s type system. | |
| # | |
| # In class today, we saw that having one inherit from the other doesn’t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body.app-body.layout-multiple-columns.theme-mastodon-light, | |
| body.app-body.layout-multiple-columns.theme-default, | |
| body.app-body.layout-multiple-columns.theme-contrast { | |
| overflow: hidden !important; | |
| } | |
| body.app-body.layout-multiple-columns.theme-mastodon-light .columns-area, | |
| body.app-body.layout-multiple-columns.theme-default .columns-area, | |
| body.app-body.layout-multiple-columns.theme-contrast .columns-area { | |
| margin: 0 -1px !important; |
In Wordy, suppose that BinaryExpressionNode were designed like this, with the operator modeled as a string:
public class BinaryExpressionNode extends ExpressionNode {
// Valid operator types include "addition", "subtraction", "multiplication",
// "division", and "exponentiation". Other strings are not valid operators.-
Generalized existentials 😄 In progress!
- Use case: implement
Resource<T>, Siesta’s most obvious API design gap - Use case: silly dances like this
- Use case: implement
-
✅ $0 ≠ all params
- Use case: I specifically made the more-frequently used closure arg the second one here so that code referencing only it as
$1would compile (where it would not if it were$0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ------ Base class with metaprogramming ------ | |
| # This might make more sense if you skip ahead to the 🦄🦄🦄🌈🌈🌈 first | |
| # and study the desired results, then come back here. | |
| class Animal | |
| def initialize(name) | |
| @name = name | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Model with property observers: | |
| Model = function() {} | |
| Model.prototype.observe = function(prop, observer) { | |
| this._observers = this._observers || {} | |
| if(!this._observers[prop]) { | |
| this._observers[prop] = [] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # CLOSURES IN RUBY Paul Cantrell http://innig.net | |
| # Email: username "cantrell", domain name "pobox.com" | |
| # I recommend executing this file, then reading it alongside its output. | |
| # | |
| # Alteratively, you can give yourself a sort of Ruby test by deleting all the comments, | |
| # then trying to guess the output of the code! | |
| # A closure is a block of code which meets three criteria: |
Swift Evolution proposals for the three features I covered:
Here's a good (and mildly critical) overview of dynamic member lookup.
Python interop:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // WHY HAVE A TIMER SYNCED TO DISPLAY REFRESH? | |
| // | |
| // Sparked by this question from Nick Lockwood: | |
| // https://twitter.com/nicklockwood/status/1131650052701786114 | |
| class TimerPhasingSimulation | |
| { | |
| // –––––– Heart of the simulation –––––– |
NewerOlder