Array length

1 개요[편집]

len
length
count
  • 배열의 길이

2 Bash[편집]

systems=("Solar System" "Alpha Centauri" "Barnard's Star")
echo ${#systems[@]}
# 3
echo ${#systems[*]}
# 3

3 C#[편집]

string[] weekDays2 = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
MessageBox.Show(weekDays2.Length);
// shows 7

4 Java[편집]

String[] weekDays2 = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
System.out.println(weekDays2.length);
// shows 7

5 JavaScript[편집]

var weekDays2 = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ];
document.write(weekDays2.length);
// shows 7

6 Objective-C[편집]

NSArray *weekDays2 = [NSArray arrayWithObjects:@"Sun", @"Mon", @"Tue", @"Wed", @"Thu", @"Fri", @"Sat", nil];
NSLog(@"%lu", [weekDays2 count]);
// shows 7

7 Perl[편집]

@nums = (1,2,3,4);
print scalar(@nums);
# shows 4

8 PHP[편집]

16px-Crystal_Clear_app_xmag.svg.png PHP count() 문서를 참고하십시오.
$nums = [1,2,3,4];
echo count($nums);
// shows 4

9 POSIX Shell[편집]

WEEKDAYS2="Sun Mon Tue Wed Thu Fri Sat"
echo $WEEKDAYS2 | tr ' ' '\n' | grep -cP '\S+'
# 7

10 Python[편집]

16px-Crystal_Clear_app_xmag.svg.png Python len() 문서를 참고하십시오.
nums = [1,2,3,4]
print len(nums)
# shows 4

11 R[편집]

16px-Crystal_Clear_app_xmag.svg.png R언어 length() 문서를 참고하십시오.
x <- c("apple","banana","orange")
cat( length(x) )
# 3
cat( length(diag(4)) )
# 16

12 Ruby[편집]

nums = [1,2,3,4]
puts nums.size
# shows 4

13 같이 보기[편집]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}