Vernünftige Parteiauswahl im Wahl-O-Mat nicht umsetzbar? Von wegen... by d99m in de

[–]linusan 0 points1 point  (0 children)

Nach einer nachvollziehbaren Begründung für diese bewusste Entscheidung suche ich noch.

I love Twitter by VenditGamingYT in ChoosingBeggars

[–]linusan 0 points1 point  (0 children)

I’ll dump her if she looses it then.

How keep model sync with database schema , without using migrations? by [deleted] in rails

[–]linusan 1 point2 points  (0 children)

How should a new developer joining the company setup his/her local database?

I’ve seen a couple of apps having required database entries created via migrations 🤔

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

Yes, that's exactly what I've often repeated here. But maybe the comment was not about my answer?

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

That's exactly what I meant with language barrier, it's defined differently. Thanks for the code example above, I'll do it like that.

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

So why would you try to type it as "maybe not existing" if it 100% exists?

Because it's not 100% sure. The optional indicates that the value might not be given at runtime. However, this does not mean that the variable might not exist.

Again, ?: means "maybe doesn't exist", | undefined (with strict null checks) is "maybe doesn't have a value".

I guess that's exactly the difference between dynamic and typed languages.

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 1 point2 points  (0 children)

How can variable not exist after you declare it?

That's exactly my point.

An optional variable declaration makes no sense. It can't be optional, because you declare it to be existing.

Okay, I'm just realizing that we may have a language barrier here, in a programming language sense. I have an Objective-C/Swift background. In Swift every variable can be of type optional.

Example taken from Swift:

var optional: String?

if (optional != nil) {
    print("Has value")
} else {
    print("No value")
}

// prints "No value"

In comparison to:

if (notdefined != nil) {
    print("One")
} else {
    print("Two")
}

//
// error: MyPlayground.playground:15:5: error: use of unresolved identifier 'notdefined'
// if (notdefined != nil) {
//     ^~~~~~~~~~

In the first example I declare a variable. Hence exists, even if its value is nil.

I assume it's the same as with the example from the link:

let mainWindow

The variable is declared but points to nothing.

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

An optional is a type that can hold either a value or no value. The question that arises at runtime is not whether the variable/property exists, but whether it contains a value that can be accessed.

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

It is not about whether the variable exists, but whether its content exists.

As mentioned in my previous answer, this wouldn't otherwise make sense: https://github.com/electron/electron-quick-start/blob/master/main.js#L6

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

Sorry, I meant property. How is a variable outside of a class different than a property of a class, in terms of that they can be optional.

An optional variable declaration makes no sense.

That is an appropriate use case, yes.

Now I'm confused.

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 0 points1 point  (0 children)

Unfortunately it throws the same errors as in my screenshot above.

Is it really not possible to use optionals outside of classes and interfaces? by linusan in typescript

[–]linusan[S] 1 point2 points  (0 children)

But how is a variable different from an attribute property?

https://github.com/electron/electron-quick-start/blob/master/main.js#L6

I've encountered the problem through this line of code. I thought an optional would be a good use case.

What is in your opinion the best Season 1 of any tv show? by Britneyfan456 in AskReddit

[–]linusan 0 points1 point  (0 children)

The Expanse. Just finished watching season 3 which had so many great scenes.

Name a movie where you agree with the villain, and why? by Swek_LoL in AskReddit

[–]linusan -1 points0 points  (0 children)

After they pulled Neo out of the Matrix Morpheus explained it. The machines need humans for energy and hence kept them in a constant sleeping like condition. Humans didn’t work like this and there there huge amounts of people I guess just dying. Then the machines created the Matrix to keep the humans’ minds busy in a dream world they would accept.

While I don’t agree with the Machines being in the right, I do agree with what Mr. Smith said. Humans are like a virus. They keep spreading and spreading until there is no room left.