|
Is there any difference between p and puts in Ruby?
Started by collimarco on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
P foo is the same as puts foo.inspect
It is also important to note that puts 'reacts' to....
It prints the value of inspect instead of to_s , which is more you can't when printing without inspect ) .
P foo does puts foo.inspect , i.e.
|
|
I am using Ruby 1.8.6 for the following code:
# Create an array and override the #to_s on that object thing = [1,2,3] def thing.to_s 'one' end print "Using print: " print thing puts puts "Using puts: " puts thing
Output:
Using print: one Using puts: 1...
Started by arnab on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If any of the arguments to puts passed directly as an argument to puts....
puts is one of the most common output does not already end with a newline character, it adds one.
Are, and you can write values to them with the << operator .
|
|
Hi,
What's the configuration setting to get calls to puts to be written to the Apache log file? (Using Passenger to run Rails on Apache)
Thanks
Started by Paul on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
STDOUT (p, puts, printf, pretty_print...) is perfect por script/console experiments and for debugger calls, see this: post about ruby-debug for some hints on how to use "puts" or "p.
Enough ,everywhere.
|
Ask your Facebook Friends
|
Hi, I am working on creating a daemon in Ruby using the daemons gem. I want to add output from the daemon into a log file. So I am wondering what is the easiest way to redirect puts from the console to a log file?
Started by Josh Moore on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
To use ruby logger, it is better than puts, you can have multiple log levels that you can turn on/off.
|
|
In a rake task if I use puts command then I see the output on console. However I will not see that message in log file when app is deployed on production.
However if I say Rails.logger.info then in development mode I see nothing on console. I need to ...
Answer Snippets (Read the full thread at stackoverflow):
Anything that needs to be kept for posterity ("sent warning email) if RAILS_ENV == "development" puts info else logger.info info end end
Then call output_debug instead of puts or logger.info
....
Be output on the terminal with puts .
|
|
LaTeX tries to guess whether a period ends a sentence, in which case it puts extra space after it. Here are two examples where it guesses wrong:
I watched Superman III. Then I went home.
(Too little space after "Superman III.".)
After brushing teeth etc...
Started by dreeves on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
So the first example should be
I watched sidestep the spacing issue if you prefer single spaces at the end of sentences: put \frenchspacing.
The fix is to put " \@ " before the period.
Sentence space.
|
|
I'm working on a Ruby TCP client/server app using GServer and TCPSocket. I've run into a problem that I don't understand. My TCPSocket client successfully connects to my GServer, but I can only send data using puts. Calls to TCPSocket.send or TCPSocket...
Started by nathan on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Are you sure ....
Try explicitly flushing:
tcp_client = TCPSocket.new( ipaddr, port ) tcp_client.write( 'Z' ) tcp_client.send( 'Z' ) tcp_client.flush
This way, the output is buffered at most only until the point at which you decide it should be sent out .
|
|
I have recently moved a database from Sql Server 2000 to Sql Server 2005. In the table designer, it insists on putting square brackets around a column named "Content" I don't see Content on the list of reserved words for Sql Server, so I don't understand...
Started by pthalacker on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Sql....
The problem is that the field has the same name as the table .
You can always add square brackets around a column name so it doesn't hurt anything .
No, you can't prevent it.
See here.
CONTENT is a keyword when defining an XML column with a schema .
|
|
What's the difference between...
File.open('abc', 'w') { |f| f.puts 'abcde' }
...and...
File.open('abc', 'w') { |f| f.write 'abcde' }
...?
Started by Ethan on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Technically, puts appends the record separator (which.
puts appends a newline, write does not.
|
|
The following code does not work correctly on Windows (but does on Linux):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setblocking(True) sock.connect(address) gobject.io_add_watch( sock.fileno(), gobject.IO_OUT | gobject.IO_ERR | gobject...
Started by Matt Joiner on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Only ask for....
When I write programs like this I tend to do the following:
Buffer the bytes I want to send to the file descriptor .
Is there a problem with doing non-blocking I/O? It seems kind of strange to use polling loops if you're using blocking I/O .
|