|
Thinking about it a bit more, I think you should be able to use the Elvis operator, which in this case will assign a length of 0 if the username is null:
val length = username?.length ?: 0
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
In C languages (including Java) asserts were supposed to crash the program if they ever evaluated to false.
Not something you would want to use if it ever could be null.
And asserts should never include side effect logic. Part of the primitive toolset that led to “Contract” based programming .
|
|
|
|
|
I have a header file that is just tables of possible/must/must-not break actions depending on character combinations.
This is due to Unicode Standard Annex 14 and Unicode Standard Annex 29. Presumably because the committee hadn't made things difficult enough already, they decided to turn line breaking into a Rube Goldberg contraption.
I'm sure they have reasons for all of this, and if they could corner me in a dark alley they'd explain them to me at length, but at the end of the day coding against the Unicode standards is like flossing a cat - everybody ends up unhappy and someone might be going to the emergency room.
I wish I could have just used OpenType.
Real programmers use butterflies
|
|
|
|
|
I'm impressed (14; 29).
Like finding the missing appendix (that no one else seems to be aware of) from an old PDF that's been circulating. I did; and it made all the difference in understanding the main body.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Somebody should have said: 64 characters is enough for anyone.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Worse than Vogons: Humans trying to defined rules for the royal mess other humans managed to create over many years.
You can choose only supporting English. Or do Chinese - even simpler.
Once you want to support multiple languages you end up in the mess. And don't expect you can do proper line-breaks without knowing the language of the UI. A Chinese text with an English word in it (for example a company name) should use Chinese line-break rules inside the English word. I would expect you can put western languages into the same rule set (as long as you respect non-breakable space etc) without too many problems.
|
|
|
|
|
Yeah, I'm aware the line breaking is language specific. Fortunately, EPUBs always indicate the language they are in. It's more just that the code is big, ugly, slow, and incomprehensible.
Real programmers use butterflies
|
|
|
|
|
So you want to do a Dutch accent. I get it, it's a funny accent to make fun of. But there is one feature that Dutch doesn't have: sh everywhere. That's a rare sound in Dutch. It mainly exists English loan words, that's right, you are the ones saying sh. In actual Dutch words, there are some rare cases where an s-j combo can assimilate into the sh sound (such as the name Sjaak) but that's not a phoneme.
"But I hear you guys saying that sh sound" you might say. You're not hearing it. What you're hearing is a retracted s, which has a lower pitch, but it doesn't really have that "shushing" sound of an sh. It's not produced by blowing air between the tongue and the roof of the mouth, so it's not an sh. Only the tip of the tongue should go up, near the alveolar ridge. Go practice, or use a regular plain old English s, but sh sounds extremely non-Dutch.
|
|
|
|
|
So who are all these CodeProject geeks who are making fun of your language? Shander Rossel[^] maybe?
|
|
|
|
|
Shirley you meant Shander Rosshel. 
|
|
|
|
|
There's a double "s", so it's actually Shander Roshshell.
|
|
|
|
|
3rd times the charm! 
|
|
|
|
|
Well, I'm Dutch, and I think Dutch is a terrible language 
|
|
|
|
|
Are you mocking my lishp?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Why is there an s in lisp it's so unfair
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
Why is disleck... dysslekc... dyslexia so hard to spell?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have sex daily dyslexia
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
Shh! I'm going to steal that for tomorrow's CCC.
|
|
|
|
|
Leslie would solve it in a nanosecond. I used it years ago, and I don't think that was the first. My favourite anagram.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
So how you quieten the kids down if you can't go Shhhh!
// TODO: Insert something here Top ten reasons why I'm lazy
1.
|
|
|
|
|
|
They don't; they send them out to check the dikes...
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Daniel Pfeffer wrote: check the dikes 
|
|
|
|
|
If you've never had your finger in a ... I'm going to stop there ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|