Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Possible Duplicate:
How do I format my code blocks?

As the following, '<' or <--' doesn't show with pre tag. Is there any better way to write code in SO?

# Sample code from Programing Ruby, page 24
class Song
  def to_s # "
  end
end

song = Songson.new()
p song
share|improve this question

marked as duplicate by Ether, Jon Seigel, random Apr 13 '10 at 0:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Actually, yes, there is a better way. Edit this question, place your cursor in the body, and look at the editing help on the right; it should tell you how to format code. (And as a bonus, it gets syntax highlighting also.) – mmyers Apr 12 '10 at 20:40
up vote 6 down vote accepted

Yes:

# Sample code from Programing Ruby, page 24
class Song
  def to_s # <-- 
    "Song"
  end
end

class Songson < Song
  def to_s
    super + "<Songson>"
  end
end

song = Songson.new()
p song

Don't try to use HTML to format your code (or your text), simply select your code and hit the 1010 button above the text entry area.

share|improve this answer
    
You can trust the WYSIWYG buttons here! They actually work unlike most sites! – Earlz Apr 12 '10 at 23:27
    
And you don't even have to trust them, you can also hit Ctrl-K instead! – sth Apr 13 '10 at 2:05

Please see the FAQ.

In this particular case, to get the <'s to work, you'll need to indent your code 4 spaces.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .