Questions tagged [val]
26 questions
2
votes
1 answer
Add the same value labels to multiple dataframe columns using expss::val_lab
I'm trying to add the same value labels to multiple columns in a dataframe using the expss::val_lab function, but any labelling function in expss well work for me.
#Example data
ex1 <- c(1,1,2,2,3,3,4,4,5,5)
ex2 <- c(5,4,3,2,1,1,2,3,4,5)
ex6 <-…

Mike
- 23
- 4
2
votes
1 answer
Val cannot be reassigned while I try to create LinearLayout dynamically
I'm trying to create new LinearLayout with kotlin inside MainActivity.kt
for (i in 0 until tileArr.size){
var tileLayout: LinearLayout = LinearLayout(this)
tileLayout.marginBottom = 10
}
while it throws error Val cannot be reassigned on…

Nika Jobava
- 113
- 3
- 10
2
votes
2 answers
Kotlin. Data class: how to update one of the parameters?
I have data class. For example:
data class Test(
val data: String,
val data2: String
)
Suppose I have a need to change one of the parameters of my data class. For this I will write the following code:
var test = Test(data =…

testivanivan
- 967
- 13
- 36
2
votes
3 answers
Kotlin. How to declare constant?
I have class, which in primary constructor has some fields:
class SomeData(val counter: Int...) { // some logic}
I need to create a constant. I usually do it like this:
companion object {
private const val MAX_VALUE = 1000
}
But in my case,…

testivanivan
- 967
- 13
- 36
2
votes
3 answers
How do you initialize val fields with constructor params in Kotlin?
In Java you can declare a private final member variable and then initialize it from your constructor, which is very useful and is a very common thing to do:
class MyClass {
private final int widgetCount;
public MyClass(int widgetCount) {
…

Russ Jackson
- 1,993
- 1
- 18
- 14
1
vote
1 answer
Jquery input .val() returns undefined when one button triggers another button
I have multiple buttons that need to be activated at the same time. When each button is click from the input it returns what is type. The problem is I need all the buttons to be fire off at the same time. When I have a separate button fire off…

genericdude76
- 31
- 6
1
vote
3 answers
How does kotlin compiler know whether a val should be a property or a function
The following kotlin code
val nameHash get() = name.hashCode()
can be compiled into java as follows
public final int getNameHash() {
return name.hashCode();
}
and the property nameHash disapears.
However when the val is changed to var, the…

Kevin Paul
- 11
- 2
1
vote
2 answers
Javascript ignores last linebreak with text.(elem.val())
I'm trying to output a textarea value into a pre (or a div with white-space:pre for that matter). All works well, but it skips the last linebreak. So, if you add text and a linebreak, it won't display the linebreak. If you add text and two…

Paul
- 37
- 7
1
vote
1 answer
In Kotlin, Why can the value of a val integer be reassigned by the inc() method?
Consider the following,
val x: Int = 0
val variables cannot be changed so doing x += 1 wouldn't work
The compiler says Val cannot be reassigned
why then does x.inc() work fine
doesn't x.inc() reassign the value from 0 to 1

Ser.T
- 51
- 4
0
votes
0 answers
jquery get list of input values after blur one
I have a plugin translate page:
In this page I insert a row of flags and a form with original text of post and inputs for translation.
At the end of form there is the submit button.
I want to activate/deactivate automatically the submit button when…

imagIne
- 49
- 1
- 6
0
votes
0 answers
Rounding up even if Python is also less than 0.5
How to Rounding up even if Python is also less than 0.5?
I use round() but if value is 3.12 less than 3.5 rounded value is 3 but I do want returned value is 4.
process it may vary depend on the enter value.
I do want:
4.2 round to = 5
1.33 round…

Tuğberk Yıldırım
- 15
- 3
0
votes
2 answers
Scala val and var with collections
I want to understand better the following issue.
When should i use var and when val?
I know that there is a rule of thumb in Scala that we should use val.
For primitive types it's easy - we should use var only if we change a variable in a loop.
My…

ni al
- 11
- 1
0
votes
3 answers
val vs var in Kotlin. Which one is more performant when declaring a variable
There are some rumors which claims that var is more performant than val in context of declaring a variable in kotlin since it does not have and does not need a immutability mechanism. I could not find any resources which only focuses to "declaring a…

Sevban Bayır
- 196
- 3
- 13
0
votes
0 answers
Val cannot be reassigned in function of Kotlin
I was trying to create a recursive function to delete a node of a Binary Search Tree using Kotlin language. During the same I encountered this compile time error saying "Val cannot be reassigned.".
I see from similar questions here that parameters…

JavaBoi
- 37
- 4
0
votes
1 answer
YOLOV8 test MAP score
I can calculate the map score of the validation set using yolo version 8. but is there any way to calculate the MAP of the test score?
The code for calculating the map of the validation set is given below:
!yolo task=detect mode=val…

Airah
- 41
- 4