Backspace character

In December I asked a question: What’s wrong with this code? I agree that the question was rather broad without context. I just asked it in the same way a friend asked me.

Many people noticed '\b' character in the code… Is it good or bad? Well, it depends.

What is '\b' character?

Quote from an answer by T.J. Crowder at Stack Overflow: On most terminals or consoles, '\b' is a nondestructive backspace. It moves the cursor backward, but doesn’t erase what’s there.

Another answer provides a detailed explanation of how the backspace character works.

If you’re interested, see The “backspace” escape character ‘\b’ in C, unexpected behavior? question.

What can be wrong?

As long as the output is written to terminal or console, it does what it’s supposed to do, most of the time at least. But what about capturing the output to a file? Then you’ll see a weird character in the file.

In my opinion, backspace character in that code serves no purpose. Much better way would be just to remove the last space from the buffer:

sb.deleteCharAt(sb.length() - 1);

It is the safest approach and it has no (possible) undesirable effects.

Another issue is if objs is empty, the opening '[' would be removed from the string. I think the assumption here is that objs is never empty which can be enforced by the calling code.



It’s so true :))

Firefox: switching between tabs in most recently used order

Recently I stumbled upon a statement that new Opera 18 does not remember most recently used tabs when switching between them with Ctrl+Tab. In classic Opera, the last version 12.16, pressing Ctrl+Tab switched to the previously used tab: this way it’s easy to switch between the two tabs just like between two applications with Alt+Tab in Windows.

I still use the classic version of Opera, and I didn’t see the change. In Firefox, pressing Ctrl+Tab switches between the tabs in the order they were opened: from the first to the last tab as they appear on the tab panel. But you can change the behavior.

  1. Open a new tab in Firefox (Ctrl+T).
  2. Type about:config into the address bar and press Enter.
  3. Click I'll be careful, I promise!.
  4. Type ctrl into the Search field above the list of settings.
  5. Double-click the line with setting browser.ctrlTab.previews.
    The value in the Value column would change to true, and Status — to user set.
  6. Close the tab (Ctrl+W).

Now when you press Ctrl+Tab, Firefox would switch you to the most recently used tab. If you hold Ctrl for a while, you’ll see a window with tab previews; if you press the keys fast enough, the preview window won’t appear and the browser will switch to another tab.

I used this answer (by Jonathan Williams) to the question Changing Firefox Tab Cycle Order (by Mark Roddy).
сс-wiki aka cc-by-sa