type-coercion Questions
1
Consider the minimally reproducible example:
f = @(x) x
f(end)
Note, the MATLAB syntax highlighter doesn't actually highlight end in blue, showing that it is not parsing as a keyword, even though ...
Legal asked 10/9 at 8:24
3
Solved
What is the relationship between reference of tuple and tuple of reference as types?
Why does the first works but the second doesn't?
let a = 1;
let b = 2;
// This works, c: &i32, d:&i32
le...
Caresa asked 29/3, 2023 at 16:53
2
Solved
This is a simple example:
object CoerciveCovariance {
trait Cov[+T]
def cast[A, B](v: Cov[A])(
implicit
ev: A <:< B
) = {
v: Cov[B]
}
}
It doesn't compile:
CoerciveCovariance.scala...
Vaasta asked 16/3, 2023 at 22:51
2
Solved
When doing rustlings standard_library_types/iterators2.rs, I started wondering how std::iter::Iterator::map calls its argument closure/function. More specifically, suppose I have a function
// &quo...
Garth asked 7/6, 2021 at 1:9
2
Solved
I would like to define a button's padding the same way as in C# XAML files. Instead of writing things like:
<Button fx:id="btn1" ...>
<padding>
<Insets top="0" right="5" bottom="1...
Unearthly asked 20/8, 2019 at 11:14
7
Solved
I am trying to achieve the functionality similar to unlist, with the exception that types are not coerced to a vector, but the list with preserved types is returned instead. For instance:
flatten(...
Samal asked 15/11, 2011 at 16:29
4
Solved
I'm comparing strings with comparison operators.
I need some sort of explanation for the below two comparisons and their result.
if('ai' > 'i')
{
echo 'Yes';
}
else
{
echo 'No';
}
output: No
...
Heartburn asked 15/10, 2012 at 2:50
5
I know == operator performs the type coercion. But I can't understand the below behaviour.
const x = new Boolean(false);
if (x) {
console.log("if(x) is true");
}
if (x == false) {
c...
Bracketing asked 15/2, 2019 at 23:44
2
Solved
Let's say I have a value defined as a sort of commission formula
let address_commission = 1.0 // minimal simplified example
and I want to apply the above said commission to an amount I'm reading...
Hocuspocus asked 26/5, 2017 at 11:5
1
Solved
Given that a literal number not strictly an instance of Number, why can I call prototype methods of Number (or String, or Boolean) objects on the corresponding literal objects? Is this standard beh...
Depression asked 8/11, 2016 at 15:55
2
Solved
According to the ECMA script standard, the following code should return true, but it doesn't:
d = new Date() ;
d.setTime(1436497200000) ;
alert( d == 1436497200000 ) ;
Section 11.9.3 says:
...
Buhler asked 1/7, 2015 at 19:53
1
Solved
According to this table in the ECMAScript standard, string values that have length 0 should be evaluated as boolean false.
How come, then, these statements evaluate to true?
"\t" == false
" " == ...
Thaddeusthaddus asked 19/11, 2014 at 20:4
2
Solved
It is said that when we have a class Point and knows how to perform point * 3 like the following:
class Point
def initialize(x,y)
@x, @y = x, y
end
def *(c)
Point.new(@x * c, @y * c)
end
en...
Japha asked 9/5, 2010 at 23:26
3
Solved
I program in Java, C and Python.
The rule for automatic coercions among arithmetic types have been
augmented to handle the richer set of types
Source: "The C Programming Language"...
Lawsuit asked 18/6, 2012 at 15:34
2
Solved
Why does (int 10) not produce an instance of type java.lang.Integer?
; why Long here?
=> (type (int 10))
; java.lang.Long
; this one is also Long, why not java.lang.Number?
=> (type (num 10...
Wildawildcat asked 26/2, 2012 at 21:54
2
Solved
I've been reading about JavaScript hoisting sometime back.
JavaScript Scoping and Hoisting by Ben Cherry
Two words about “hoisting” by Dmitry Soshnikov
and, some more about JavaScript type-coercio...
Eugenie asked 20/7, 2011 at 17:37
3
Solved
The following code in Groovy adds GStrings to the list:
List<String> args = [ 'cmd', "-Dopt=${value}" ]
When I create a ProcessBuilder with this list, I get a ClassCastException. What's a ...
Crossness asked 6/7, 2011 at 7:6
4
Solved
In JavaScript...
'\t\n ' == false // true
I can assume that any string that consists solely of whitespace characters is considered equal to false in JavaScript.
According to this article, I fig...
Unread asked 12/4, 2011 at 11:24
1
Solved
data: function( elem, name, data ) {
if ( !jQuery.acceptData( elem ) ) {
return;
}
elem = elem == window ? windowData : elem;
Copied directly from the jQuery source.
Why is it not safe to us...
Minutes asked 31/1, 2011 at 2:0
1
© 2022 - 2024 — McMap. All rights reserved.