Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Created August 12, 2015 12:37
Show Gist options
  • Save KittyGiraudel/fae0424c7afb833767eb to your computer and use it in GitHub Desktop.
Save KittyGiraudel/fae0424c7afb833767eb to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
/// Very dummy implementation of spaceship operator (<=>) in Sass
/// which returns 1, -1 or 0 depending of the result of the comparison
/// between values $a and $b
/// @link https://wiki.php.net/rfc/combined-comparison-operator
/// @param {Number} $a - First value
/// @param {Number} $b - Second value
/// @return {Number} - 1, 0 or -1
@function spaceship($a, $b) {
@if $a > $b { @return 1; }
@if $a < $b { @return -1; }
@return 0;
}
.foo {
content: spaceship(42, 1337);
content: spaceship(1337, 42);
content: spaceship(42, 42);
}
.foo {
content: -1;
content: 1;
content: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment