Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

12-09-2017 , 01:32 PM
Quote:
Originally Posted by jmakin
I've stubbornly refused to use the ternary operator for years because of a C++ professor that would randomly throw a question about it in every single exam and I'd mess up the syntax every time.

i used it in my last project and holy **** it's actually really useful. I'm such a scrub, lol.
Maybe the problem is because of grammar.

a ? b : c

looks like a and b are grouped together more than b and c, but really b and c are more alike. Getting rid of some spaces might make it easier to remember.

a? b:c
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 01:56 PM
Quote:
Originally Posted by microbet
Maybe the problem is because of grammar.



a ? b : c



looks like a and b are grouped together more than b and c, but really b and c are more alike. Getting rid of some spaces might make it easier to remember.



a? b:c


I just read it in my head as a? then b, else c
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 02:22 PM
haha yep, me too.

Last edited by _dave_; 12-09-2017 at 02:23 PM. Reason: nesting them tho, plz never
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 03:55 PM
I've thought about the use of nested ternarys, is it something considered clever or just ugly?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 04:12 PM
It's just hard to read, even if it makes sense to you when you write it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 04:24 PM
Quote:
Originally Posted by ChrisV
From what I understand, the other Java IDEs are worse.

It's probably fine software once you understand how to use it, but it's hellishly unintuitive. As one trivial example, when you mouse over stuff in Visual Studio, let's say a method, it will pop up a tooltip with method signature. To get a similar thing in IntelliJ, you hold down Ctrl and mouse over stuff. I know that because I googled it. The most obviously annoying thing there is how undiscoverable it is - who tries holding down Ctrl and mousing over stuff? But the thing that really blows my mind is that this wasn't done to make way for some other function - just mousing over stuff doesn't do anything. They apparently just decided to make the IDE miles less intuitive and discoverable for no reason at all.



The Project Structure dialog has a different version of a library specified than everywhere else in the project. My project was failing at runtime because it was trying to find a version of the library that no longer existed. I have no clue where IntelliJ stores the information it shows in Project Structure and so far nobody has been able to tell me. I have tried running a search on my whole hard drive and reading documentation and I still have no idea. The problem happened after someone else updated the libraries in the project, so apparently source control doesn't have the files it needs to update the version specs. I was able to fix it manually within IntelliJ, but it will probably just break again next time libraries are updated. As a soapboxy aside, every settings editor should have a little thing you can click that says "show me the file where these settings are stored".
The CTRL keybindings are probably ported from OSX, where command key is pretty standard for doing this kind of stuff. Since most Java/web companies are using macbooks not windows, Intellij is much better experience/more intuitive on that platform.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 04:45 PM
how can i make the command

echo "hello" >> Gemfile

add "hello" at a specific line number in Gemfile?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 05:21 PM
Quote:
Originally Posted by OmgGlutten!
how can i make the command

echo "hello" >> Gemfile

add "hello" at a specific line number in Gemfile?
Welcome to the wonderful world of sed
https://stackoverflow.com/questions/...-specific-line
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 05:38 PM
A double arrow is a redirect that adds to the bottom of the file. Not sure what OMGs intention is here, but creating a brand new file with only "hello" at some line number?

Here's an example that gets "hello" at line 6.

Code:
yes "" | head -n 5 > one.txt; echo "hello" >> one.txt
Elegant and easy to read, IMO.

If you want it at some line number below the bottom, it's kind of a strange request...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 10:15 PM
The best use case for ternaries is when you want to initialize a variable as one thing or another based on conditions.

Code:
const myVar = (someCond) ? 'hey' : 'you';
is far cleaner than any other method

Code:
const myVar = 'you';
if (someCond) myVar = 'hey'
is gross

Code:
const myVar;
if (someCond) myVar = 'hey';
else myVar = 'you';
is even worse
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 11:07 PM
uhhhhhh not to be that guy but the bottom 2 in javascript typeerror so even grosser
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 11:10 PM
type error?

Oh lol duh - should be let
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 11:26 PM
If there are more than 2 conditions are you doing switch case or something similar?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 11:31 PM


4chan still going strong btw pretty crazy. They mostly keep to themselves though. Weird, weird people.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-09-2017 , 11:40 PM
I only use switch statements in redux reducers.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-10-2017 , 12:23 AM
Also, I hear people don't like them, but using them in reducers is great so would recommend the concept generally.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-10-2017 , 12:40 AM
Quote:
Originally Posted by kerowo
If there are more than 2 conditions are you doing switch case or something similar?
More than two I might have a default case, then conditionally change it - like in option 2. I almost never use switch.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-10-2017 , 12:44 AM
Quote:
Originally Posted by Larry Legend
I've thought about the use of nested ternarys, is it something considered clever or just ugly?
Quote:
Originally Posted by goofyballer
It's just hard to read, even if it makes sense to you when you write it.
if properly formatted, they're the easiest to read:

Code:
ifx ? a :
ify ? c :
ifz ? d : e
it's just a case statement with less cruft
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-10-2017 , 01:45 AM
Wow that just made nested ternarys make so much sense
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2017 , 02:56 AM
That example is not a nested ternary. Here would be an example of one.

Quote:
ifx ?
ifsubx ? ab : ac :
ify ? c :
ifz ? d : e

Last edited by Craggoo; 12-11-2017 at 03:03 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2017 , 03:01 AM
Can't get the code to be indented. the ifsubx bit should be indented.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2017 , 03:31 AM
They're both nested ternaries imo, just structured differently. But I think it raises a valid point, which is that not all nested ternaries structure nicely like gaming_mouse's did. Craggoo's is an example of when nested ternaries are unclear code and should be avoided.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2017 , 03:36 AM
Quote:
Originally Posted by ChrisV
They're both nested ternaries imo, just structured differently. But I think it raises a valid point, which is that not all nested ternaries structure nicely like gaming_mouse's did. Craggoo's is an example of when nested ternaries are unclear code and should be avoided.
My interpretation of a nested ternary is a nested if/else block. That is exactly what I did. The example given is just an if/elseif/else type of chain. I'm not sure how that qualifies as a nested ternary. There would be no nested blocks if was re-written as an if/else/elseif block.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2017 , 03:46 AM
Quote:
Originally Posted by Craggoo
My interpretation of a nested ternary is a nested if/else block. That is exactly what I did. The example given is just an if/elseif/else type of chain. I'm not sure how that qualifies as a nested ternary. There would be no nested blocks if was re-written as an if/else/elseif block.
Depends how you look at it I guess. Elseif is syntactic sugar for nested if blocks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2017 , 04:28 AM
Quote:
Originally Posted by ChrisV
Depends how you look at it I guess. Elseif is syntactic sugar for nested if blocks.
Not even remotely.

Code:
if (a == 1) {
    if (b) {...}
    else {....}
is not the same as

Code:
if (a == 1) {...}
elseif (b) {...}
When a = 1

There is no fallthrough if the conditions happen to match multiple blocks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m