473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

printing a redacted word in an if loop

heiro1
29
My code won't print "REDACTED" in place of the redact variable. I do not know why though. Can anyone shed some light? I appreciate it! Here is my code :

Expand|Select|Wrap|Line Numbers
  1. puts "Whats your input brah?"
  2. text = gets.chomp
  3. puts "Whatchu are you hiding bro?"
  4. redact = gets.chomp
  5. words = text.split(" ")
  6. words.each {|x| if x == redact print "REDACTED"+" " else print x+" "}
Apr 25 '13 #1
2 5961
heiro1
29
This code definitely works if I use "do" instead of the curly braces. I tested it. The tutorial I am using said that those two are the same thing and can be used inter-changably but as I found, it doesn't work when I use curly brackets. Unless I am missing something important.
Apr 25 '13 #2
heiro1
29
I found the answer already but thank you if you were about to post something helpful!

Expand|Select|Wrap|Line Numbers
  1. puts "Whats your input brah?"
  2. text = gets.chomp
  3. puts "Whatchu are you hiding bro?"
  4. redact = gets.chomp
  5. words = text.split(" ")
  6. words.each {|x| if x == redact then print "REDACTED"+" " else print "#{x}"+" " end}
Apr 25 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andy Newland | last post by:
Hi Guys, I would like to print out a word document using a VB .NET component. I have got VBA and VB.Net talking to each other and can pass word objects between COM and .NET. My reason for...
2
by: SSK | last post by:
hi i was trying to print a word document from a stored prcedure using the following two methods 1) cd C:\&&"C:\Program Files\Microsoft Office\OFFICE11\winword.exe" "c:\temp.doc" /mfileprint ...
0
by: Les Desser | last post by:
We currently use Word documents, saved as OLE objects in the database, to print letter headings and the like. As this bloats the database, we would like to store instead the path (as text or...
4
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be...
5
by: Stefania Scott | last post by:
I am trying to print a word document from Access. The code I've written works well in my computer but does not in the one were it is needed. Here the piece of code: 'doc path strObjectPath =...
3
by: David | last post by:
Hello, hope someone can help. I have a request to print word .doc check lists with selected records in Access for surgery procedure cards. I have hyperlinked the word doc's to a field in each...
5
by: CJ Taylor | last post by:
I've been looking everywher efor this but all I can find is that Word's automation library doesn't allow you to pick a printer programatically... Anyone know of a soluition? Thanks, cJ
9
by: ewolfman | last post by:
Hi, I need to provide the user with the option to click something, and what follows is: 1. Download a word document, without displaying winword. 2. Printing the document to the default printer...
17
by: wparrott | last post by:
Hello experts! I'm having trouble coding a button on a form and could use some help. In a nutshell, I'm attempting to code the button to do the following: 1. Choose the appropriate Word...
0
sueb
by: sueb | last post by:
I have a document with a watermark. In Word 2003, this watermark doesn't print but is only displayed (which is exactly what I want). However, in Word 2007, this watermark is printed and I can't...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.