Depends on the object what happens when they are moved from. Some objects are put into a valid moved from state (usually depends on if doing so is free or required anyway. For example to satisfy the invariant of the moved to unique pointer the moved from pointer needs to be set to nullptr in order to prevent the moved tos unique pointer being deleted from underneath it)
Traister101
Yo whatup
- 0 Posts
- 42 Comments
Because it sounds like English words which is “cool”
Eyy I just watched Red Ranger, extremely enjoyable for how stupid it is. I bet I’d have loved power rangers if I watched it as a kid
I can’t judge but wow. Impressive
You cannot have a string argument, arguments and variables in JS don’t have a type. All you have in JS is objects. Actual functions, like full on
function foo(){}
are still objects, like you can actually store data on the things.
JavaScript doesn’t have typed parameters or variables. The function expects a string and does things in the function body which converts the object into a string. JS shares this behavior with all dynamically typed languages and it’s extremely useful in some contexts and extremely frustrating in others. It’s down to what it’s being used for. Dynamic languages make excellent scripting languages, see Python really just being a souped up shell lang
It’s not a string argument though, it’s JS. You can argue it’s expected to be a string but like the rest of JS all you can know from the signature alone is that it takes an object. Hopefully your little ducky quacks the right way!
Even Java has streams and stuff. Course Java so it’s kind of weird (iterators are mutable and internally iterate the collection/whatever lazily) streams are lazy and only go through all the operations, mapping, filtering ect when you collect the elements somehow (like rust). JS is wild lol
Traister101@lemmy.todayto Programming@programming.dev•Vibe Coding is not an excuse for low-quality work9·2 months agoWhat ramdon ass language could they possibly be pulling out of their ass for you to he completely unable to write a for loop? I’ve yet to see a for loop, or really any sort of loop that doesn’t look pretty much exactly like the standard C style for loop
for(int x = 0; x < z; x++) { }
If you have a C style language with iterator for loops like C++, Java and friends you almost certainly have this syntax
for(int x : numbers) { }
Python has exclusively iterator for loops with this syntax
for x in range(z)
The only real difference is that instead of a colon
:
you use thein
token.At best I can see the need for a quick refresh on what the exact syntax is but if your a senior any languages you actually use should have a template for junk like this. I don’t think I’ve manually written a loop in ages, I just type out
iter
for an iterator for loop or when I rarely need an indexfori
and the rest gets stamped out for me.If your being tested on random languages you can simply just not be familiar with a language. I haven’t touched Zig once but I’d totally be down to learn it. Everybody whos got a couple languages under their belt knows how easy it is to pick up new ones.
Traister101@lemmy.todayto Rust@programming.dev•crates.io security incident: improperly stored session cookies5·3 months agoLol but no essentially somebody accidentally logged the ID for an actively logged in user (not the user ID) when an error happens. Surprising they even released a thing about this
Ah yes now I can… dereference a raw pointer (yes that’s essentially the only thing unsafe rust actually enables you to do, it doesn’t disable the borrow checker or anything else, it just allows you to play with pointers)
Traister101@lemmy.todayto Programming@programming.dev•[Noob here] Can someone explain to me the advantage of mutable objects?9·5 months agoSo your writing a game. This game has what I’m going to call “entities” which are the dynamic NPCs and such objects. So these objects are most easily conceptualized as mutable things. Why mutable? Well they move around, change states depending on game events ect. If this object is immutable you’d have to tie the in world representation to a new object, constantly just because it moved slightly or something else. This object is mutable not just because it’s easier to understand but there are even efficiency gains due to not needing to constantly create a new version just because it moved a little bit.
In contrast the object which holds the position data (in this case we’ll have 3 doubles x, y, z) makes a lot of sense as an immutable object. This kind object is small making it cheap to replace (it’s just 3 doubles, so 3*64 bits or a total of 24 bytes) and it’s representing something that naturally makes sense as being immutable, it’s a set of 3 numbers.
Now another comparison your typical dynamic array type container (this is your
std::vector
std::vec
ArrayList
and friends). These are mutable objects mainly due to efficiency (it’s expensive to copy the contents when adding new values) yet they also are easier to conceptualize when mutable. It’s an object containing a collection of stuff like a box, you can put things in, take stuff out but it’s still the same box, just it’s contents have changed. If these objects are immutable to put something into the box you must first create a brand new box, and create a copy of the old boxes contents, and then put your new item into the box. Every time. Sometimes this kind of thing makes sense but it’s certainly not a common situation.Some functional languages do have immutable data structures however in reality the compiler usually does some magic and ends up using a mutable type as it’s simply so much more efficient.
So what’s 0 do then? I’m okay with wacky indexes (I’ve used something with negative indexes for a end-index shorthand) but 0 has to mean something that’s actually useful. Using the index as the offset into the array seems to be the most useful way to index them.
If your joking yes, if your not Java and Java Script are seperate things.
Traister101@lemmy.todayto Programming@programming.dev•Rant: I wish more people stopped using Github3·6 months agoGithub outside of hosting the actual git repo largly just provides good routes for collaboration, namely issues, their PR system and some convenient rules on who is allowed to mess with branches and how (IE you can set master to only accept merges done via github themselves). CI is the real lock in far as your git repo is concerned cause that just won’t work at all on another host
Uninitalized memory (
int a;
with no assignment) vector of int vectors (IE a dynamicint[][]
) and attempting to finda
, anint
in the vector of vectors of int IEint
instead ofvector<int>
. I think the iterator type is correct but I’m not sure off the top of my head
Traister101@lemmy.todayto Programming@programming.dev•Malicious code injection by compromised pull request branch names23·7 months agoOkay? I’m well aware. I do so all the time
Traister101@lemmy.todayto Programming@programming.dev•Malicious code injection by compromised pull request branch names1·7 months ago/
is used to separate the same branch in different repos. For exampleorigin/main
andremote/main
. Surprising that the other stuff is legal though
Traister101@lemmy.todayto Programmer Humor@programming.dev•Next month is gonna be rough282·7 months agoYou don’t have to be religious to think a fat dude in some red clothes that magically travels around the world giving out presents to good children isn’t a fun yearly tradition. Frankly it’s kind of an overdramatic reaction to a small red hat overlaid onto an icon. Should configuration be provided to disable the functionally? Sure I don’t care, hell have it disabled by default I don’t mind but it’s stupid to make a huge stink about something so minor.
Douno off the top of my head. To take a wild guess they might just wrap a file handle and give it s nice api? If that’s what they do then moving from the file zeros out he handle for basically the same reason smart pointers set their internal pointer to nullptr, so they don’t delete it (or close the file in this case) underneath the new object.