Skip to content

Instantly share code, notes, and snippets.

@iamskok
Last active August 31, 2015 23:28
Show Gist options
  • Save iamskok/c7b0e7e6b03b65923a0c to your computer and use it in GitHub Desktop.
Save iamskok/c7b0e7e6b03b65923a0c to your computer and use it in GitHub Desktop.
Equal-lists Sass function
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$v1: 1 2 3;
$v2: 4 5 6;
$v3: 7 8 9;
.test {
// Is there any shorthand for that?
// @Hugo: see the function below
content: (length($v1) == length($v2)) == (length($v2) == length($v3));
// Why this is not working ?
// @Hugo: because this is translated to *is `true` equal `3`?*, which is `false`
content: ((length($v1) == length($v2)) == length($v3));
// Why this is not working ?
// @Hugo: same as above
content: (length($v1) == length($v2) == length($v3));
}
@function equal-lists($lists...) {
@if length($lists) < 2 {
@return true;
}
$length: length(nth($lists, 1));
@for $i from 2 through length($lists) {
@if length(nth($lists, $i)) != $length {
@return false;
}
}
@return true;
}
.test {
content: equal-lists($v1, $v2, $v3);
}
.test {
content: true;
content: false;
content: false;
}
.test {
content: true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment