Questions tagged [types]
Types, and type systems, are used to enforce levels of abstraction in programs.
types
28,955
questions
-1
votes
2
answers
51
views
uint8_t elements exceeding one byte?
I saw this code:
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
I know uint8_t holds a byte, so how does this line of code work when a single
element, 0xFF, is in itself one whole ...
0
votes
0
answers
6
views
R visNetwork arrow type
The below code is meant to yield the following network graph:
.
library(visNetwork)
library(magrittr)
nodes <- data.frame(id=c("a","b","c","d"), label=c(&...
1
vote
3
answers
67
views
In C, why can a variable holding a char array be assigned to a pointer, but the address of the same pointer cannot?
Consider the following code:
char stringy[] = "There's too much confusion, I can't get no relief!";
char *pStringy;
pStringy = stringy;
This compiles -
stringy is an array of characters, ...
0
votes
1
answer
86
views
Write a new Delphi type that lets a method have inline code as a parameter?
Is it possible to have this in Delphi?
DoThis(ShowMessage('SomeMsg ..'); Caption := 'SomeCaption'; Inc(I));
Is it possible to create a new type that handles inline code like this?
For example, we ...
-2
votes
0
answers
16
views
What should I prefer input type for voice synthesis [closed]
I decide to make my artificial neural network for synthesis my voice but still I am not sure about what I use for input type. Should I use input type as letter or syllable?
I still not start the ...
1
vote
1
answer
39
views
R get local variable from formula
Consider the R code :
foo <- function(formula){
Y <- get(formula[[2]])
print(Y)
}
main <- function(){
Y <- 1
X <- 2
foo(Y ~ X)
}
main()
The outcome says that in get(...
0
votes
0
answers
21
views
check if given object implements certain generic interface; type argument(s) NOT known [duplicate]
I have some object. I want to check at runtime if it is an IReadOnlyCollection<T> of any T, i.e. I cannot specify that T in my check. So it should return true for e.g. IReadOnlyCollection<...
0
votes
0
answers
29
views
As a wrapper object in JavaScript, why can not use 'new' to create a BigInt in JavasScript? [duplicate]
There are 5 wrapper objects in JavaScript: Number, BigInt, String, Boolean, and Symbol.You can use 'new' to create a Number, String, Boolean, Symbol. But you can not use 'new' to create a BigInt. what ...
-2
votes
0
answers
75
views
Are there objects for primitive data types? [duplicate]
If the object represents a data type, is the variable for a primitive data type like an integer also an object representing this type, or do objects not represent primitive data types?
// Let's assume ...
0
votes
0
answers
38
views
Why print(f"{variable = }") in Python 3.12 also prints numpy type?
I noticed, that with Python 3.12 and a numpy.float64 when I simply do a
x = numpy.sqrt(3) # type is <class 'numpy.float64'> now
print(f"{x = }")
# this is printed
>>>x = np....
0
votes
1
answer
52
views
How to enforce error on impossible switch case?
There is a linter we can enable for equality check. What about switch case ? This does not seem to work. https://stackoverflow.com/a/78736339/6727914
How to convert the warning into errors ?
Example:
...
-1
votes
0
answers
59
views
Why doesn't a type switch case with multiple types assign the detected type to the variable? [closed]
In Go, I want to understand some design choices in the type switch. The following example works as expected:
package main
import "fmt"
func abs[T int | float64](a T) T {
if a >= 0 {
...
3
votes
1
answer
59
views
How to enforce error on impossible equality check?
There is a linter to it https://dart.dev/tools/linter-rules/unrelated_type_equality_checks but it just shows a warning, rendering it almost useless for large projects.
How to convert the warning into ...
-1
votes
1
answer
55
views
Go type assertion (any) [duplicate]
This seems likely to be a duplicate but I couldn't find a solution. Please point me in the right direction if it is a duplicate
I am relatively new to Go and here I am trying to create a helper ...
1
vote
0
answers
15
views
Why am I having an issue with typescript and Prisma ORM when trying to find a unique item?
I am having issues with my ability to use the prisma .findUnique() function call. My code doesn't show any compilation error, but when I actually try to go to a product page it causes a runtime error.
...