Skip to main content

Questions tagged [option-type]

The option type or maybe type is a polymorphic type that represents encapsulation of an optional value where one side encapsulates the value, and other side represents the absence of the value (None, Nothing, etc). This tag is adequate for questions about `Option` in Scala, `Optional` in Java and Swift, `std::optional` in C++ and similar types.

option-type
0 votes
3 answers
118 views

Cannot Stream average() undefined for OptionalDouble

I'm using this code but eclipse shows an error saying stream() is undefined for the type OptionalDouble The error shown by eclipse is The method stream() is undefined for the type OptionalDouble . ...
nvn's user avatar
  • 159
0 votes
0 answers
47 views

How to create working powershell module with optional flags

I have a function that I am trying to make unto a module to use in my daily sripts. I want it to work kind of like (writeI -host "hello" -fore red -back black" where it has flags and ...
Fried Synapse's user avatar
0 votes
1 answer
223 views

How to resolve incompatible type Optional type conflict?

Hi anyone know how to resolve this error in py3? Getting error message like: "int" has incompatible type "Union[float, int, str, None]"; expected "Union[str, bytes, ...
Lalaphoon's user avatar
  • 359
0 votes
1 answer
53 views

Concise way to deal with missing values

I'm looking for a way to gracefully and concisely handle different cases in which one or another value may be absent. A concrete example use case could be to log which values were absent, as ...
Stefan Reisner's user avatar
1 vote
1 answer
309 views

What's the Idiomatic Way in Kotlin to Use Streams with map and orElseThrow?

I am transitioning from Java to Kotlin and am used to working with Java Streams. I have the following two Kotlin snippets that essentially do the same thing: they attempt to create a retrospective ...
JangoCG's user avatar
  • 916
0 votes
1 answer
440 views

Lazy initialisation of lazy_static?

I've already had some success with lazy_static: static ref WORD_COUNT_REPORTING_STEP_MUTEX: Arc<Mutex<usize>> = Arc::new(Mutex::new(0)); static ref INDEX_NAME: RwLock<String> = ...
mike rodent's user avatar
  • 15.1k
1 vote
1 answer
44 views

Why typescript cannot refer the type in my example correctly?

Considering the code for Option ADT as below (pretty similar to fp-ts Option): export type Option<A> = Some<A> | None export interface Some<A> { _tag: 'Some' value: A } export ...
Shnd's user avatar
  • 2,000
0 votes
1 answer
107 views

std::optional with Eigen::ArrayBase

template <typename Derived> std::optional<Eigen::Array<typename Derived::Scalar, Eigen::Dynamic, Eigen::Dynamic>> function1(const std::optional<Eigen::ArrayBase<Derived>>&...
Helloexcel's user avatar
0 votes
1 answer
91 views

Implementing the Option Functor in Julia - while maintaining type stability

First off, I have created the following attempt at an Option-type in Julia: # building an Option-type abstract type MyNothing end struct None{T} <: MyNothing end Option = Union{Some{T},None{T}} ...
David Reynolds's user avatar
0 votes
1 answer
51 views

How to filter out all valid typed values from an optional typed array in Ballerina

How to filter all valid typed values from an optional typed array in Ballerina? This can be done using foreach like below, int?[] input = [1, 2, (), 3, 4, ()]; int[] output = []; foreach int? i in ...
Azeem Muzammil's user avatar
0 votes
2 answers
1k views

Bootstrap 5 is not working after I using Select2 dropdown

The Select2 functionality is functioning correctly. However, there is an issue with Bootstrap, after using Select2, Bootstrap is not working anymore. I am using Bootstrap 5.3.The picture show that the ...
Sim Lee's user avatar
3 votes
2 answers
162 views

What are good strategies for handling Option - Some(null) in F#

I am new to the F# language and encountered exceptions when pattern matching Some and None using an Option type with a string value. This was discovered using FSCheck. Given a (string option) property ...
Jorge Cuervolini's user avatar
1 vote
2 answers
160 views

Chaining Optional and Stream in Java(preferably 11)

I have a list of Foo objects, where each Foo contains a name and a List<Strings>. I am trying to find if the fooList contains a Foo object with a target name, and if such element exists, find ...
de5tro's user avatar
  • 33
-2 votes
1 answer
195 views

How to fix this force cast in swift

I am facing this below issue in my project, kindly help me to fix this issue. Force Cast Violation: Force casts should be avoided. (force_cast) var guestNetworks: [WanNetworks] { for result in ...
B.Saravana Kumar's user avatar
1 vote
3 answers
56 views

Return type depending on optional generic type Typescript

I made the following function to generate an object (map) [key] : value from an array. I want to make the value method optional, and in this case just return the item as it is. Here is my code : ...
TCH's user avatar
  • 533

15 30 50 per page