What is a variable? [closed] - variables

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Do you have a good example of html code of a variable, my teacher confuse me and I have no idea how to learn it, I just need an easy example of a code i can look on and a little explanation , sorry for bad english. My question is, what is a variable?

HTML doesn't have variables, as it is a markup language, not a programming language.
Javascript, on the other hand, does allow variable use. For example, you can initialize a variable:
let x = 3
Compare the variable to other values:
if (x === 4) {
console.log("x is equal to 4!");
}
And even reassign it!
x = 4
This is useful if you want to implement a counter; you can have a variable initialized at 0 and then increment it each time a user presses a button (by setting an onclick handler).

Related

Can I use kotlin "also" function just to shorten the code? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Do kotlin docs say anything about using the also() function just to reduce code lines? I mean doing some unrelated work in the lambda body and not using the it parameter.
For example instead of this:
fun togglePeriod() {
viewModel.togglePeriod()
showStatistics()
}
I've written this:
fun togglePeriod() = viewModel.togglePeriod().also { showStatistics() }
The code should be readable and express the intention. Reducing the line count for the sake of reducing line count rarely results in the readability improvement.
If toggling a period should result in displaying statistics it makes perfect sense to have a separate togglePeriod() method body, it shows the intention nicely. also() doesn't feel as readable.

How to show in console? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to show a square with number of edge is entered from keyboarded.
I wrote as C++. It's OK.
But as Objectvive C. It's not OK.
Please help me. How to fix it.
I can tell that you printed every * with a separate call to NSLog. Don't use NSLog if you need precise control over the format of the output.
Since Objective-C is a superset of C, you have the entire C standard library available in your Objective-C program. Just use printf or puts or putchar to print your square.

Make Label Straight using AWCollectionViewDialLayout – Cocoa Controls [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am using AWCollectionViewDialLayout demo provided on git below is the link:- https://github.com/awdigital/AWCollectionViewDialLayout
I want to make labels straight.
Please Help.
In your specific example, your cell itself is rotated, not just the label. So you cannot only make the label straight and keep the image rotated.
If you still wants to make both element straight, take a look on the source file of the libarary. You are looking for variable called rotationT
on line 181. Just keep its value to 0 and have a try

Is it faster to compare or reassign a bool in a loop? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
The question is: is it faster to do that:
if (!self.isStarted)
{
self.started = YES;
}
or simply:
self.started = YES;
and reassign the value at each passing loop.
The conditional is slower, and isn't as clear as simply setting the variable to YES. The point of your code is that you want to ensure the variable is YES after you leave that bit of code, and since the operation is so inexpensive in the grand scheme of things, go for readability, and just set it to YES without checking beforehand.
While a compiler would likely optimize this anyway, self.started = YES; will be faster, because it saves the overhead of having to retreive the value from memory and compare it. This answer is only valid for low-level languages; higher-level languages will be implementation dependent.

what does this multi-dimensional array looking thing actually mean? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
#interface Foo {
Bar *bar[12][8][2];
}
And I am wondering what that means and what it is actually doing behind the scenes?
bar it is an array of 12 elements. Each element is an array of 8 elements, and each element is an array of 2 pointers to "Bar" objects.
No surprises -- It is a multi-demensional array of pointers to Bars.
In MRC, reference counts are managed manually.
In ARC, they are managed for you.