dreamrealI know. But what does teh contains() METHOD imply?
dreamrealIt says "this sequence can or cannot be found in the instance being referred to," yeah?
wedrFrom the doc, it says "Returns true if and only if this string contains the specified sequence of char values."
dreamrealIt takes a CharSequence, is called on a String. Right?
wedrYes
dreamrealOkay, what does it say ABOUT THE SPECIFIED SEQUENCE?
wedrAn empty string implies that it is a non-null CharSequence object?
Parawedr: FWIW you can as an exercise implement contains, substring and a few other basic operations using char arrays and as simple as possible constructs (for loops with manual index management and such) and you'll kinda see why the things behave like they do.
ParaAnd yes, "" indeed is not null :)
wedrUgh, I gotta go back and fix a 6 years old bug.
fizzieHere's one way to think about it, if you like: a.contains(b) is true iff a.substring(x, y).equals(b) for some x, y.
dreamrealThere you go. Does "foo" contain a valid but empty "" sequence? yes.
ParaBeen poking at code from 2017 myself lately...
dreamrealwedr: always fun to realize you left out a constraint, innit :/
wedr* wedr is baffled.
dreamrealthankfully, it's never happened to ME! ... pardon me while I check a shedload of codebases to scrub
dreamrealfor, uh, something else entirely, surely
dreamrealit'd not baffling! Any nonempty string contains an empty-but-valid sequence
dreamrealit's indexOf() in the end, although codepages factor in
ParaThis reminds me of a discussion I see every now and then - not commonly but still - where someone doesn't quite get why empty collection is not the same as null. Different problem entirely, but there's some logical overlap.
fizzie"foo" contains "" in four different places, even.
Parafizzie: regex split agrees
wedroh no, I now see why, but goddamnit it's not that intuitive until you see it.
dreamrealhmm, I can understand that
dreamrealI don't know that I AGREE with it, but I can understand it
wedranyway, we have so many string checks throughout the code, so I will have to check them all.
ParaAnd another overlap, with URIs the path segment of URI is handled in sort of similar way. This is why path "/" is different than "", or "foo/" has two segments while "foo" has just one.
ParaThis latter part is also why it's potentially a security defect to do URI rewrites involving trailing path.
ParaAnd people do that a lot as cargo culting because back in the day Apache directory serving used that to sniff whether you mean foo-the-dir or foo-the-file.
* Drixtan joined #java
* hwpplaye` joined #java
* mwnaylor left #java (ERC 5.6.0.30.1 (IRC client for GNU Emacs 30.2))
* JazzJackalope joined #java
* acidsys joined #java
* sponkz joined #java
* m2 joined #java
* llanhmock joined #java
* hwpplayer1 joined #java
* Drixtan joined #java
* tomboy64 joined #java
* ztevoz joined #java
* keb joined #java
* nimaje joined #java
* ferdna joined #java
* Odyss3us joined #java
* magla joined #java
* Betal joined #java
* Ragnor joined #java
* nimaje joined #java
* henbruas joined #java
* magla joined #java
* akaWolf1 joined #java
* akaWolf1 joined #java
* nimaje joined #java
* nimaje joined #java
jreicherI think the term "empty string" could be confusing, and is probably a misnomer. It kind of suggests there's no string there, but there is of course still a (zero-length) string.
jreicherIt's not like "empty list", because a list is a collection. A string isn't really a collection in some ways.
* nimaje joined #java
MaxdamantusHow is it different? "empty set", "empty list", "empty string", "empty sequence" .. I think these are all understood in pretty much the same way.
MaxdamantusThere is a set/list/string/sequence, and the fact that it's empty means its length is 0.
dreamrealheh. What's the intersection of the ['a', 'b', 'c'] and [] sets?
MaxdamantusJust like how an empty bottle has 0 contents in it.
Maxdamantus[]
jreicherBy people who understand them, yes. But I think people who don't are getting caught by the fact that a String (the java object) is not a collection.
dreamrealat what position is the [] set in the first set?
Maxdamantussets don't have positions.
jreicherYou can interpret as a string as a collection (of chars), but you need that interpretation
dreamrealyeah, but those aren't JAVA sets, assume they're ordered
ParaI suspect at least some of the confusion I mentioned earlier has caused by teachers wanting to overfeed functional programming theory as the only way to see programming.
jreicherBut it is... :p
ParaLike cool, Set(3) is also identity of 3 in a set...and no one cares.
MaxdamantusWell, a string is a thing that has a length or size. That's what allows it to be conceptually empty.
Maxdamantusgtg
dreamrealI'm still very vaguely annoyed that teachers don't start with actual ML
dreamrealon, like, eight bit processors
jreicherOh, come on. Nobody says "empty distance", do they?
ParaGenZ slang is kinda like that, apparently.
ParaAnyway. One issue that I've seen a few time is that people really don't understand that the collection itself has functionality and properties tied to its type. Like set and its ordering.
ParaThey'll just blank on "how can identy of nothing be unordered" kind of mismash.
Para(I meet a person like this maybe once every few years, mind you)
ParaSo, about monads...
jreicherYou mean enchiladas.
Parammm, those would be nice
ParaCan't really get good ones over here.
jreicherGood Mexican food is very good food.
* nimaje joined #java
* nimaje joined #java
* nimaje joined #java
jreicherI had the wrong control codes before but I think this channel strips them anyway. Was trying to do italics