PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > IO#gets(sep_string) usage
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
IO#gets(sep_string) usage

Réponse
 
LinkBack Outils de la discussion
Vieux 16/09/2007, 16h29   #1
ZyLo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut IO#gets(sep_string) usage

Hello all. I'm trying to use the gets function, only I want to read
in a file and make separators any sort of punctuation(",", ":", "\n",
etc.).

My problem is trying to understand how the sep_string=$/ option is
supposed to work:

ios.gets(sep_string=$/)

How can I specify what sep_string is so that when I do something for a
while loop on gets, I can get each word instead of a line of text, or
lines of text with various punctuation I don't want?

A second note, I'm not sure what $/ is supposed to mean. Is that the
separator for newline(which i thought was \n)?

Thanks in advance.

  Réponse avec citation
Vieux 16/09/2007, 17h51   #2
Wilson Bilkovich
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: IO#gets(sep_string) usage

On 9/16/07, ZyLo <Klauer@gmail.com> wrote:
> Hello all. I'm trying to use the gets function, only I want to read
> in a file and make separators any sort of punctuation(",", ":", "\n",
> etc.).
>
> My problem is trying to understand how the sep_string=$/ option is
> supposed to work:
>
> ios.gets(sep_string=$/)
>
> How can I specify what sep_string is so that when I do something for a
> while loop on gets, I can get each word instead of a line of text, or
> lines of text with various punctuation I don't want?
>
> A second note, I'm not sure what $/ is supposed to mean. Is that the
> separator for newline(which i thought was \n)?
>


$/ is the 'output separator' global. It defaults to \n.
What that syntax is saying is that you can pass a separator string to
IO#gets, and it will use it. If you don't pass it one, it will use
whatever $/ is set to.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h23.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08051 seconds with 10 queries