I do I write this in .LESS? [duplicate] - less

This question already has answers here:
Immediate Child selector in LESS
(5 answers)
Closed 4 years ago.
I have a css output and I want to write this code in .LESS I see it uses the ">" to target down.
how do you write that in less to target with ">"
.clever-menu ul.clever-mega-menu > li.level0.active > a span

This is the equivalent in LESS
.clever-menu {
ul.clever-mega-menu {
> li.level0.active {
> a span {
color: black;
}
}
}
}

Related

Kotlin if else and let issue, can't add a command [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
Maybe I'm too tired, but when adding the following Log.d in the code (now commented out) the , Studio shows a compile error on the last "else if" (where (formId == 98))... Please advise
formViewModel?.questionGeneralData?.id?.let { formId ->
if (formId == 10 && !interactor.getIsRetroactive()) {
interactor.setCaffeineCounter(answer.toString())
// Log.d("5732", "455ryhrdhgbfhbdrfhbg")
} else if (formId == 14) {
if (answer == 0) {
if (BuildConfig.FLAVOR == BOOST_FLAVOR) {
interactor.addSkippedForm(15, FormEnums.FormType.MORNING_FORM)
} else {
interactor.addSkippedForm(15, FormEnums.FormType.MORNING_FORM_REFRESH)
}
} else {
interactor.removeSkippedForm(15)
}
} else if (formId == 97 && !interactor.getIsRetroactive()) {
HomeSharedPrefs.put(SleepApp.getInstance().applicationContext, caffeineTaken, answer)
} else if (formId == 98 && !interactor.getIsRetroactive()) {
HomeSharedPrefs.put(SleepApp.getInstance().applicationContext, alcoholTaken, answer)
}
}
I would say that when you do that, the return type of that first if statement is different than all the other statements. Since the let function (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/let.html) expects a type for the return value that might be causing this compilation issue.
Use .also instead OR return same data-type from all if-else branches.
Also, put that log statement above interactor.setCaffeineCounter(answer.toString()).
Based on Joao Dias answer, the solution is to switch places the Log.d with the line before it (put it after the Log.d), so first the Log is executed, and then the line after it runs, and returns the value, that the let expects

Sass, marking a variable as a string [duplicate]

This question already has answers here:
Sass Interpolation of Mixin, Function, and Variable names
(3 answers)
Closed 8 years ago.
I'm trying to run a loop in Sass to generate the following variables:
$size-xs: 1em;
$size-sm: 1.1em;
$size-md: 1.2em;
$size-lg: 1.3em;
This is what I have so far:
$size-base:1em;
$size-increment:0.1em;
$size-list: "xs","sm","md","lg";
#each $value-size in $size-list {
$size-#{$value-size}:#{$i};
$i:$size-base + $size-increment;
}
The problems I'm having is the $size- is interpreted as a variable, but it's not, it's the root of a set of variables I'd like to generate. Any ideas on how to accomplish this?
Thanks so much for any help!
The error you were getting was because variable names can't be interpolated like that. (You were also trying to use $i before it was defined.)
But you can directly name the elements that will be styled. For example:
$size-base: 1em;
$size-increment: 0.1em;
$size-list: "xs", "sm", "md", "lg";
#each $value-size in $size-list {
$size-base: $size-base + $size-increment;
.#{$value-size} {
font-size: $size-base;
}
}
You can even just output silent placeholders instead of elements, and then extend them when needed.
$size-base: 1em;
$size-increment: 0.1em;
$size-list: "%xs", "%sm", "%md", "%lg";
#each $value-size in $size-list {
$size-base: $size-base + $size-increment;
#{$value-size} {
font-size: $size-base;
}
}
h2 {
#extend %lg;
}
This will only compile the h2 style declaration.
See the example at http://sassmeister.com/gist/a400ded59756a814c47e.

Golang test stdout [duplicate]

This question already has answers here:
How to test a function's output (stdout/stderr) in unit tests
(3 answers)
Closed 3 years ago.
I am trying to test some functions that print ANSI escape codes. e.g.
// Print a line in a color
func PrintlnColor(color string, a ...interface{}) {
fmt.Print("\x1b[31m")
fmt.Print(a...)
fmt.Println("\x1b[0m")
}
I tried using Examples to do it, but they don't seem to like escape codes.
Is there any way to test what is written to stdout?
Using fmt.Fprint to print to io.Writer lets you control where the output is written.
var out io.Writer = os.Stdout
func main() {
// write to Stdout
PrintlnColor("foo")
buf := &bytes.Buffer{}
out = buf
// write to buffer
PrintlnColor("foo")
fmt.Println(buf.String())
}
// Print a line in a color
func PrintlnColor(a ...interface{}) {
fmt.Fprint(out, "\x1b[31m")
fmt.Fprint(out, a...)
fmt.Fprintln(out, "\x1b[0m")
}
Go play

Comparing NSStrings seems not to work [duplicate]

This question already has answers here:
Comparing Strings in Cocoa
(5 answers)
Compare two NSStrings
(3 answers)
Closed 10 years ago.
I am having some very frustrating trouble on what I'm sure is a very simple problem, but I cannot seem to fix it. I have an NSArray called final that outputs as follows:
final = (
".DS_Store",
"hey.txt"
)
I want the following for loop to return false for the first pass and true for the second. As far as I can tell I have it made correctly but the output is true for both passes.
for (int i = 0; i < [final count]; i++) {
if (final[i] != #".DS_Store") {
NSLog(#"true");
}
else {
NSLog(#"false");
}
Outputs:
2013-02-20 17:20:39.042 myAppName [40636:403] true
2013-02-20 17:20:39.042 myAppName [40636:403] true
I cannot figure out why the first one does not return false. Any Ideas?
You are comparing pointers. Use [final[i] isEqualToString:#".DS_Store"] to compare strings.

How to increment a variable in Scss with a for loop? [duplicate]

This question already has answers here:
Creating or referencing variables dynamically in Sass
(7 answers)
Closed 7 years ago.
Pretty sure this isn't possible with Sass/Scss but want to be certain that this is a limitation of Sass rather than my own misunderstanding of the syntax...
I'm trying to create a list of styles where each list item gets a different color assigned from a bunch of variables:
$color1: #FF0000; // Red
$color2: #FFBF00; // Orange
$color3: #FFFF00; // Yellow
$color4: #7FFF00; // Green
$color5: #007FFF; // Light Blue
$color6: #00FFFF; // Cyan
$color7: #0000FF; // Blue
$color8: #7F00FF; // Purple
$color9: #FF00FF; // Magenta
#for $i from 1 through 9 {
a[href^="link#{$i}"] { color: $color#{$i};
}
}
However, the Sass won't compile. I'm thinking it's just not possible to increment the variable name in this manner. Can anyone confirm?
You can't create variable names in a dynamic way, but you can achieve this with even better semantics and flexibility:
$red : #FF0000;
$orange : #FFBF00;
$yellow : #FFFF00;
$green : #7FFF00;
$lightblue : #007FFF;
$cyan : #00FFFF;
$blue : #0000FF;
$purple : #7F00FF;
$magenta : #FF00FF;
$colors: $red $orange $yellow $green $lightblue $cyan $blue $purple $magenta;
#each $color in $colors {
$i: index($colors, $color);
a[href^="link#{$i}"] { color: $color; }
}
UPDATE: In Sass 3.3, you can use a map for less repetition.
$colors: (
red : #FF0000,
orange : #FFBF00,
yellow : #FFFF00,
green : #7FFF00,
lightblue : #007FFF,
cyan : #00FFFF,
blue : #0000FF,
purple : #7F00FF,
magenta : #FF00FF,
);
#each $name, $color in $colors {
a[href^="link#{$name}"] { color: $color; }
}